|
| 1 | +// |
| 2 | +// DynamicTableView.swift |
| 3 | +// Example-iOS |
| 4 | +// |
| 5 | +// Created by Zac on 14/02/2020. |
| 6 | +// |
| 7 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +// of this software and associated documentation files (the "Software"), to deal |
| 9 | +// in the Software without restriction, including without limitation the rights |
| 10 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +// copies of the Software, and to permit persons to whom the Software is |
| 12 | +// furnished to do so, subject to the following conditions: |
| 13 | +// |
| 14 | +// The above copyright notice and this permission notice shall be included in all |
| 15 | +// copies or substantial portions of the Software. |
| 16 | +// |
| 17 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +// SOFTWARE. |
| 24 | +// |
| 25 | + |
| 26 | +import Foundation |
| 27 | +import UIKit |
| 28 | + |
| 29 | +internal protocol QuickTableViewDelegate: class { |
| 30 | + func quickReload() |
| 31 | +} |
| 32 | + |
| 33 | +open class QuickTableView: UITableView { |
| 34 | + internal weak var quickDelegate: QuickTableViewDelegate? |
| 35 | + |
| 36 | + override open func reloadData() { |
| 37 | + self.quickDelegate?.quickReload() |
| 38 | + super.reloadData() |
| 39 | + } |
| 40 | + |
| 41 | + // MARK: Rows |
| 42 | + |
| 43 | + override open func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { |
| 44 | + self.quickDelegate?.quickReload() |
| 45 | + super.reloadRows(at: indexPaths, with: animation) |
| 46 | + } |
| 47 | + |
| 48 | + override open func insertRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { |
| 49 | + self.quickDelegate?.quickReload() |
| 50 | + super.insertRows(at: indexPaths, with: animation) |
| 51 | + } |
| 52 | + |
| 53 | + override open func deleteRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { |
| 54 | + self.quickDelegate?.quickReload() |
| 55 | + super.deleteRows(at: indexPaths, with: animation) |
| 56 | + } |
| 57 | + |
| 58 | + override open func moveRow(at indexPath: IndexPath, to newIndexPath: IndexPath) { |
| 59 | + self.quickDelegate?.quickReload() |
| 60 | + super.moveRow(at: indexPath, to: newIndexPath) |
| 61 | + } |
| 62 | + |
| 63 | + // MARK: Sections |
| 64 | + |
| 65 | + override open func reloadSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { |
| 66 | + self.quickDelegate?.quickReload() |
| 67 | + super.reloadSections(sections, with: animation) |
| 68 | + } |
| 69 | + |
| 70 | + override open func deleteSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { |
| 71 | + self.quickDelegate?.quickReload() |
| 72 | + super.deleteSections(sections, with: animation) |
| 73 | + } |
| 74 | + |
| 75 | + override open func insertSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { |
| 76 | + self.quickDelegate?.quickReload() |
| 77 | + super.insertSections(sections, with: animation) |
| 78 | + } |
| 79 | + |
| 80 | + override open func reloadSectionIndexTitles() { |
| 81 | + self.quickDelegate?.quickReload() |
| 82 | + super.reloadSectionIndexTitles() |
| 83 | + } |
| 84 | + |
| 85 | + override open func moveSection(_ section: Int, toSection newSection: Int) { |
| 86 | + self.quickDelegate?.quickReload() |
| 87 | + super.moveSection(section, toSection: newSection) |
| 88 | + } |
| 89 | +} |
0 commit comments