diff options
author | Mark Wei <markwei@google.com> | 2013-10-24 14:51:54 -0700 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2013-10-29 20:22:10 -0700 |
commit | 9c6ac19d4a3d39b7c2992060957920118ff56a65 (patch) | |
tree | 7ee9bd8104520b791f101c4e037795e16e3ec30c /src/com/android/bitmap/DecodeTask.java | |
parent | 46616414f6dabb6d57b0ac433a5fabe2abb8b5a9 (diff) | |
download | bitmap-9c6ac19d4a3d39b7c2992060957920118ff56a65.tar.gz |
Relax BasicBitmapView to allow non-BasicBitmapDrawables to be assigned to it.
Rename BasicBitmapView to BitmapDrawableImageView.
Allow asynchronous creating of file.
Change-Id: I0407bf0bf36ae92ce45d2175121a15483f8f72f2
Diffstat (limited to 'src/com/android/bitmap/DecodeTask.java')
-rw-r--r-- | src/com/android/bitmap/DecodeTask.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/com/android/bitmap/DecodeTask.java b/src/com/android/bitmap/DecodeTask.java index c90d772..3bb1252 100644 --- a/src/com/android/bitmap/DecodeTask.java +++ b/src/com/android/bitmap/DecodeTask.java @@ -25,6 +25,7 @@ import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor.AutoCloseInputStream; import android.util.Log; +import com.android.bitmap.RequestKey.FileDescriptorFactory; import com.android.bitmap.util.BitmapUtils; import com.android.bitmap.util.Exif; import com.android.bitmap.util.RectUtils; @@ -49,9 +50,9 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> { private final RequestKey mKey; private final DecodeOptions mDecodeOpts; + private final FileDescriptorFactory mFactory; private final DecodeCallback mDecodeCallback; private final BitmapCache mCache; - private final BitmapFactory.Options mOpts = new BitmapFactory.Options(); private ReusableBitmap mInBitmap = null; @@ -85,17 +86,20 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> { } /** - * Create new DecodeTask. - * - * @param requestKey The request to decode, also the key to use for the cache. - * @param decodeOpts The decode options. - * @param callback The callback to notify of decode state changes. - * @param cache The cache and pool. - */ + * Create new DecodeTask. + * + * @param requestKey The request to decode, also the key to use for the cache. + * @param decodeOpts The decode options. + * @param factory The factory to obtain file descriptors to decode from. If this factory is + * null, then we will decode from requestKey.createInputStream(). + * @param callback The callback to notify of decode state changes. + * @param cache The cache and pool. + */ public DecodeTask(RequestKey requestKey, DecodeOptions decodeOpts, - DecodeCallback callback, BitmapCache cache) { + FileDescriptorFactory factory, DecodeCallback callback, BitmapCache cache) { mKey = requestKey; mDecodeOpts = decodeOpts; + mFactory = factory; mDecodeCallback = callback; mCache = cache; } @@ -131,14 +135,15 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> { } Trace.beginSection("create fd and stream"); - fd = mKey.createFd(); - Trace.endSection(); - if (fd == null) { + if (mFactory != null) { + fd = mFactory.createFileDescriptor(); + } else { in = reset(in); if (in == null) { return null; } } + Trace.endSection(); Trace.beginSection("get bytesize"); final long byteSize; @@ -155,8 +160,8 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> { if (fd != null) { // Creating an input stream from the file descriptor makes it useless // afterwards. - Trace.beginSection("create fd and stream"); - final ParcelFileDescriptor orientationFd = mKey.createFd(); + Trace.beginSection("create orientation fd and stream"); + final ParcelFileDescriptor orientationFd = mFactory.createFileDescriptor(); in = new AutoCloseInputStream(orientationFd); Trace.endSection(); } |