Module: ProMotion::Table::Refreshable
- Included in:
- ProMotion::Table
- Defined in:
- lib/ProMotion/table/extensions/refreshable.rb
Instance Method Summary collapse
- #end_refreshing ⇒ Object (also: #stop_refreshing)
- #make_refreshable(params = {}) ⇒ Object
-
#refreshView(refresh) ⇒ Object
UIRefreshControl Delegates.
- #start_refreshing ⇒ Object (also: #begin_refreshing)
Instance Method Details
#end_refreshing ⇒ Object Also known as: stop_refreshing
24 25 26 27 28 29 |
# File 'lib/ProMotion/table/extensions/refreshable.rb', line 24 def end_refreshing return unless @refresh_control @refresh_control.attributedTitle = NSAttributedString.alloc.initWithString(sprintf(@updated_format, Time.now.strftime(@updated_time_format))) @refresh_control.endRefreshing end |
#make_refreshable(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ProMotion/table/extensions/refreshable.rb', line 4 def make_refreshable(params={}) = params[:pull_message] || "Pull to refresh" @refreshing = params[:refreshing] || "Refreshing data..." @updated_format = params[:updated_format] || "Last updated at %s" @updated_time_format = params[:updated_time_format] || "%l:%M %p" @refreshable_callback = params[:callback] || :on_refresh @refresh_control = UIRefreshControl.alloc.init @refresh_control.attributedTitle = NSAttributedString.alloc.initWithString() @refresh_control.addTarget(self, action:'refreshView:', forControlEvents:UIControlEventValueChanged) self.refreshControl = @refresh_control end |
#refreshView(refresh) ⇒ Object
UIRefreshControl Delegates
35 36 37 38 39 40 41 42 |
# File 'lib/ProMotion/table/extensions/refreshable.rb', line 35 def refreshView(refresh) refresh.attributedTitle = NSAttributedString.alloc.initWithString(@refreshing) if @refreshable_callback && self.respond_to?(@refreshable_callback) self.send(@refreshable_callback) else PM.logger.warn "You must implement the '#{@refreshable_callback}' method in your TableScreen." end end |
#start_refreshing ⇒ Object Also known as: begin_refreshing
17 18 19 20 21 |
# File 'lib/ProMotion/table/extensions/refreshable.rb', line 17 def start_refreshing return unless @refresh_control @refresh_control.beginRefreshing end |