Class: MotionPrime::TableDelegate
- Inherits:
-
Object
- Object
- MotionPrime::TableDelegate
show all
- Includes:
- DelegateMixin
- Defined in:
- motion-prime/sections/table/table_delegate.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#clear_delegated, #delegated_by
Constructor Details
Returns a new instance of TableDelegate.
5
6
7
8
|
# File 'motion-prime/sections/table/table_delegate.rb', line 5
def initialize(options)
self.table_section = options[:section].try(:weak_ref)
@section_instance = table_section.to_s
end
|
Instance Attribute Details
#table_section ⇒ Object
Returns the value of attribute table_section.
4
5
6
|
# File 'motion-prime/sections/table/table_delegate.rb', line 4
def table_section
@table_section
end
|
Instance Method Details
#init_pull_to_refresh ⇒ Object
def dealloc
pp 'Deallocating table_delegate for ', @section_instance
super
end
15
16
17
18
19
20
|
# File 'motion-prime/sections/table/table_delegate.rb', line 15
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
22
23
24
|
# File 'motion-prime/sections/table/table_delegate.rb', line 22
def numberOfSectionsInTableView(table)
table_section.number_of_groups(table)
end
|
68
69
70
|
# File 'motion-prime/sections/table/table_delegate.rb', line 68
def scrollViewDidEndDecelerating(scroll)
table_section.scroll_view_did_end_decelerating(scroll)
end
|
72
73
74
|
# File 'motion-prime/sections/table/table_delegate.rb', line 72
def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate)
table_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate)
end
|
60
61
62
|
# File 'motion-prime/sections/table/table_delegate.rb', line 60
def scrollViewDidScroll(scroll)
table_section.scroll_view_did_scroll(scroll)
end
|
64
65
66
|
# File 'motion-prime/sections/table/table_delegate.rb', line 64
def scrollViewWillBeginDragging(scroll)
table_section.scroll_view_will_begin_dragging(scroll)
end
|
#tableView(table, heightForHeaderInSection: group) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'motion-prime/sections/table/table_delegate.rb', line 26
def tableView(table, cellForRowAtIndexPath: index)
cur_call_time = Time.now.to_f
cur_call_offset = table.contentOffset.y
if @prev_call_time
time_delta = cur_call_time - @prev_call_time
offset_delta = cur_call_offset - @prev_call_offset
@deceleration_speed = offset_delta/time_delta
end
@prev_call_time = cur_call_time
@prev_call_offset = cur_call_offset
table_section.cell_for_index(table, index)
end
|