diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java')
-rw-r--r-- | mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java b/mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java new file mode 100644 index 000000000..c0245ed3f --- /dev/null +++ b/mobile/android/thirdparty/com/squareup/picasso/AssetBitmapHunter.java @@ -0,0 +1,51 @@ +package com.squareup.picasso; + +import android.content.Context; +import android.content.res.AssetManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import java.io.IOException; +import java.io.InputStream; + +import static com.squareup.picasso.Picasso.LoadedFrom.DISK; + +class AssetBitmapHunter extends BitmapHunter { + private AssetManager assetManager; + + public AssetBitmapHunter(Context context, Picasso picasso, Dispatcher dispatcher, Cache cache, + Stats stats, Action action) { + super(picasso, dispatcher, cache, stats, action); + assetManager = context.getAssets(); + } + + @Override Bitmap decode(Request data) throws IOException { + String filePath = data.uri.toString().substring(ASSET_PREFIX_LENGTH); + return decodeAsset(filePath); + } + + @Override Picasso.LoadedFrom getLoadedFrom() { + return DISK; + } + + Bitmap decodeAsset(String filePath) throws IOException { + BitmapFactory.Options options = null; + if (data.hasSize()) { + options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + InputStream is = null; + try { + is = assetManager.open(filePath); + BitmapFactory.decodeStream(is, null, options); + } finally { + Utils.closeQuietly(is); + } + calculateInSampleSize(data.targetWidth, data.targetHeight, options); + } + InputStream is = assetManager.open(filePath); + try { + return BitmapFactory.decodeStream(is, null, options); + } finally { + Utils.closeQuietly(is); + } + } +} |