lib/droiuby/support/asset.rb in droiuby-0.3.3 vs lib/droiuby/support/asset.rb in droiuby-0.3.4

- old
+ new

@@ -1,47 +1,52 @@ class BitmapDrawableWrapper def initialize(drawable) @native = drawable end - + def native @native end - + def to_bitmap @native.getBitmap end - + def height @native.getIntrinsicHeight end - + def width @native.getIntrinsicWidth end end class AssetHandler - - def initialize(url) + + 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 - - def self.download(url) - AssetHandler.new(url) + + def self.download(url, asset_type = :image) + AssetHandler.new(url, asset_type) end - + def start async.perform { result = BitmapDrawableWrapper.new(Java::com.droiuby.client.core.utils.Utils.loadAppAssetRuby(_execution_bundle, _current_app, _current_activity, - @url, Java::com.droiuby.client.core.utils.Utils::ASSET_TYPE_IMAGE, Java::com.droiuby.client.core.utils.Utils::HTTP_GET)) + @url, @asset_type, Java::com.droiuby.client.core.utils.Utils::HTTP_GET)) result }.done { |result| @block.call(result) }.start end - + def done(&block) @block = block self end -end \ No newline at end of file +end