Class: AssetHandler

Inherits:
Object show all
Defined in:
lib/droiuby/support/asset.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, asset_type) ⇒ AssetHandler

Returns a new instance of AssetHandler.



25
26
27
28
29
30
31
32
# File 'lib/droiuby/support/asset.rb', line 25

def initialize(url, asset_type)
  @url = url
  @asset_type = case asset_type
    when :image
      Java::com.droiuby.client.core.utils.Utils::ASSET_TYPE_IMAGE
    end

end

Class Method Details

.download(url, asset_type = :image) ⇒ Object



34
35
36
# File 'lib/droiuby/support/asset.rb', line 34

def self.download(url, asset_type = :image)
  AssetHandler.new(url, asset_type)
end

Instance Method Details

#done(&block) ⇒ Object



48
49
50
51
# File 'lib/droiuby/support/asset.rb', line 48

def done(&block)
  @block = block
  self
end

#startObject



38
39
40
41
42
43
44
45
46
# File 'lib/droiuby/support/asset.rb', line 38

def start
  async.perform {
    result = BitmapDrawableWrapper.new(Java::com.droiuby.client.core.utils.Utils.loadAppAssetRuby(_execution_bundle, _current_app, _current_activity,
    @url, @asset_type, Java::com.droiuby.client.core.utils.Utils::HTTP_GET))
    result
  }.done { |result|
    @block.call(result)
  }.start
end