Class: MotionPrime::TableDelegate
- Inherits:
-
Object
- Object
- MotionPrime::TableDelegate
- Defined in:
- motion-prime/sections/table/table_delegate.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#table_section ⇒ Object
Returns the value of attribute table_section.
Instance Method Summary collapse
- #clear_delegated ⇒ Object
- #delegated_by(view) ⇒ Object
-
#init_pull_to_refresh ⇒ Object
def dealloc pp ‘Deallocating table_delegate for ’, @section_instance super end.
-
#initialize(options) ⇒ TableDelegate
constructor
A new instance of TableDelegate.
- #numberOfSectionsInTableView(table) ⇒ Object
- #scrollViewDidEndDecelerating(scroll) ⇒ Object
- #scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate) ⇒ Object
- #scrollViewDidScroll(scroll) ⇒ Object
- #scrollViewWillBeginDragging(scroll) ⇒ Object
- #tableView(table, heightForHeaderInSection: section) ⇒ Object
Constructor Details
#initialize(options) ⇒ TableDelegate
Returns a new instance of TableDelegate.
4 5 6 7 |
# File 'motion-prime/sections/table/table_delegate.rb', line 4 def initialize() self.table_section = [:section].try(:weak_ref) @section_instance = table_section.to_s end |
Instance Attribute Details
#table_section ⇒ Object
Returns the value of attribute table_section.
3 4 5 |
# File 'motion-prime/sections/table/table_delegate.rb', line 3 def table_section @table_section end |
Instance Method Details
#clear_delegated ⇒ Object
14 15 16 |
# File 'motion-prime/sections/table/table_delegate.rb', line 14 def clear_delegated Array.wrap(@delegated_views).each { |view| view.setDelegate(nil) } end |
#delegated_by(view) ⇒ Object
9 10 11 12 |
# File 'motion-prime/sections/table/table_delegate.rb', line 9 def delegated_by(view) @delegated_views ||= [] @delegated_views << view end |
#init_pull_to_refresh ⇒ Object
def dealloc
pp 'Deallocating table_delegate for ', @section_instance
super
end
23 24 25 26 27 28 |
# File 'motion-prime/sections/table/table_delegate.rb', line 23 def init_pull_to_refresh return unless block = table_section.class.pull_to_refresh_block table_section.add_pull_to_refresh do table_section.instance_eval(&block) end end |
#numberOfSectionsInTableView(table) ⇒ Object
30 31 32 |
# File 'motion-prime/sections/table/table_delegate.rb', line 30 def numberOfSectionsInTableView(table) table_section.number_of_sections(table) end |
#scrollViewDidEndDecelerating(scroll) ⇒ Object
76 77 78 |
# File 'motion-prime/sections/table/table_delegate.rb', line 76 def (scroll) table_section.(scroll) end |
#scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate) ⇒ Object
80 81 82 |
# File 'motion-prime/sections/table/table_delegate.rb', line 80 def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate) table_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate) end |
#scrollViewDidScroll(scroll) ⇒ Object
68 69 70 |
# File 'motion-prime/sections/table/table_delegate.rb', line 68 def scrollViewDidScroll(scroll) table_section.scroll_view_did_scroll(scroll) end |
#scrollViewWillBeginDragging(scroll) ⇒ Object
72 73 74 |
# File 'motion-prime/sections/table/table_delegate.rb', line 72 def scrollViewWillBeginDragging(scroll) table_section.scroll_view_will_begin_dragging(scroll) end |
#tableView(table, heightForHeaderInSection: section) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'motion-prime/sections/table/table_delegate.rb', line 34 def tableView(table, cellForRowAtIndexPath: index) curCallTime = Time.now.to_f curCallOffset = table.contentOffset.y if @prevCallTime timeDelta = curCallTime - @prevCallTime offsetDelta = curCallOffset - @prevCallOffset @deceleration_speed = offsetDelta/timeDelta end @prevCallTime = curCallTime @prevCallOffset = curCallOffset table_section.cell_for_index(table, index) end |