Class: MotionPrime::ImageElement
- Inherits:
-
BaseElement
- Object
- BaseElement
- MotionPrime::ImageElement
- Defined in:
- motion-prime/elements/image.rb
Instance Attribute Summary
Attributes inherited from BaseElement
#name, #options, #screen, #section, #styles, #view, #view_name
Instance Method Summary collapse
Methods inherited from BaseElement
#add_target, after_render, before_render, #bind_gesture, #cell_element?, #cell_section?, #compute_options!, #computed_options, #dealloc, factory, #hide, #initialize, #notify_section_after_render, #notify_section_before_render, #reload!, #render, #render!, #rerender!, #show, #update, #update_options, #update_with_options
Methods included from HasClassFactory
#camelize_factory, #class_factory, #low_camelize_factory, #underscore_factory
Methods included from HasStyleOptions
Methods included from HasStyleChainBuilder
Methods included from HasNormalizer
#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value
Constructor Details
This class inherits a constructor from MotionPrime::BaseElement
Instance Method Details
#fetch_image ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'motion-prime/elements/image.rb', line 9 def fetch_image return unless [:url] raise "You must set default image for `#{name}`" unless [:default] view.setImage([:default].uiimage) refs = strong_references BW::Reactor.schedule do manager = SDWebImageManager.sharedManager manager.downloadWithURL([:url], options: 0, progress: lambda{ |r_size, e_size| }, completed: lambda{ |image, error, type, finished| return if !image || !refs.all?(&:weakref_alive?) if [:post_process].present? image = [:post_process][:method].to_proc.call([:post_process][:target], image) end self.performSelectorOnMainThread :set_image, withObject: image, waitUntilDone: true } ) end end |
#set_image(*args) ⇒ Object
33 34 35 |
# File 'motion-prime/elements/image.rb', line 33 def set_image(*args) self.view.setImage(args) end |
#strong_references ⇒ Object
37 38 39 40 41 42 |
# File 'motion-prime/elements/image.rb', line 37 def strong_references # .compact() is required here, otherwise screen will not be released refs = [section, (section.collection_section if section.respond_to?(:cell_section_name))].compact refs += section.strong_references if section refs end |
#view_class ⇒ Object
5 6 7 |
# File 'motion-prime/elements/image.rb', line 5 def view_class "UIImageView" end |