diff options
author | Sam Blitzstein <sblitz@google.com> | 2013-10-16 12:12:54 -0700 |
---|---|---|
committer | Sam Blitzstein <sblitz@google.com> | 2013-10-16 15:16:43 -0700 |
commit | 40662f4b39e795d9c64502b13036e7c37fa2d373 (patch) | |
tree | 9caf8aa9e550d9d03e167a6fd519bcf5b6b5a138 /src/com/android/bitmap/drawable | |
parent | 93a35b93dc582e38ff8ee5979754a16b4bf4da0c (diff) | |
download | bitmap-40662f4b39e795d9c64502b13036e7c37fa2d373.tar.gz |
Change BitmapRequestKey to be more cleanly implementable.
Change-Id: I831586688605e6c6c2f2f7a879c6be23175f71de
Diffstat (limited to 'src/com/android/bitmap/drawable')
3 files changed, 18 insertions, 78 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java index b16618b..2aa6011 100644 --- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java +++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java @@ -27,7 +27,7 @@ import android.util.Log; import com.android.bitmap.BitmapCache; import com.android.bitmap.DecodeTask; -import com.android.bitmap.DecodeTask.Request; +import com.android.bitmap.RequestKey; import com.android.bitmap.ReusableBitmap; import com.android.bitmap.util.BitmapUtils; import com.android.bitmap.util.RectUtils; @@ -47,7 +47,7 @@ import java.util.concurrent.TimeUnit; public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCallback, Drawable.Callback { - private BitmapRequestKey mCurrKey; + private RequestKey mCurrKey; private ReusableBitmap mBitmap; private final BitmapCache mCache; private DecodeTask mTask; @@ -81,7 +81,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCa mPaint.setFilterBitmap(true); } - public DecodeTask.Request getKey() { + public RequestKey getKey() { return mCurrKey; } @@ -98,11 +98,11 @@ public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCa setImage(null); } - public void bind(BitmapRequestKey key) { + public void bind(RequestKey key) { setImage(key); } - private void setImage(final BitmapRequestKey key) { + private void setImage(final RequestKey key) { if (mCurrKey != null && mCurrKey.equals(key)) { return; } @@ -201,10 +201,10 @@ public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCa } @Override - public void onDecodeBegin(final Request key) { } + public void onDecodeBegin(final RequestKey key) { } @Override - public void onDecodeComplete(final Request key, final ReusableBitmap result) { + public void onDecodeComplete(final RequestKey key, final ReusableBitmap result) { if (key.equals(mCurrKey)) { setBitmap(result); } else { @@ -217,7 +217,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCa } @Override - public void onDecodeCancel(final Request key) { } + public void onDecodeCancel(final RequestKey key) { } private void setBitmap(ReusableBitmap bmp) { if (mBitmap != null && mBitmap != bmp) { diff --git a/src/com/android/bitmap/drawable/BitmapRequestKey.java b/src/com/android/bitmap/drawable/BitmapRequestKey.java deleted file mode 100644 index be3a7a1..0000000 --- a/src/com/android/bitmap/drawable/BitmapRequestKey.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.bitmap.drawable; - -import android.content.res.AssetFileDescriptor; -import android.text.TextUtils; - -import com.android.bitmap.DecodeTask; - -import java.io.IOException; -import java.io.InputStream; - -/* - * Extend this base class to return either createFd() or createInputStream(). - */ -public abstract class BitmapRequestKey implements DecodeTask.Request { - public final String mUriString; - - public BitmapRequestKey(String uriString) { - this.mUriString = uriString; - } - - @Override - public abstract boolean equals(Object o); - - @Override - public abstract int hashCode(); - - @Override - public abstract String toString(); - - @Override - public AssetFileDescriptor createFd() throws IOException { - return null; - } - - @Override - public InputStream createInputStream() throws IOException { - return null; - } - - @Override - public boolean hasOrientationExif() throws IOException { - return false; - } -}
\ No newline at end of file diff --git a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java index f3a3301..01f5638 100644 --- a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java +++ b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java @@ -36,7 +36,7 @@ import com.android.bitmap.R; import com.android.bitmap.BitmapCache; import com.android.bitmap.DecodeAggregator; import com.android.bitmap.DecodeTask; -import com.android.bitmap.DecodeTask.Request; +import com.android.bitmap.RequestKey; import com.android.bitmap.ReusableBitmap; import com.android.bitmap.util.BitmapUtils; import com.android.bitmap.util.RectUtils; @@ -58,7 +58,7 @@ import java.util.concurrent.TimeUnit; public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.DecodeCallback, Drawable.Callback, Runnable, Parallaxable, DecodeAggregator.Callback { - private BitmapRequestKey mCurrKey; + private RequestKey mCurrKey; private ReusableBitmap mBitmap; private final BitmapCache mCache; private DecodeAggregator mDecodeAggregator; @@ -122,7 +122,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod mProgress.setCallback(this); } - public DecodeTask.Request getKey() { + public RequestKey getKey() { return mCurrKey; } @@ -149,11 +149,11 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod setImage(null); } - public void bind(BitmapRequestKey key) { + public void bind(RequestKey key) { setImage(key); } - private void setImage(final BitmapRequestKey key) { + private void setImage(final RequestKey key) { if (mCurrKey != null && mCurrKey.equals(key)) { return; } @@ -284,7 +284,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod } @Override - public void onDecodeBegin(final Request key) { + public void onDecodeBegin(final RequestKey key) { if (mDecodeAggregator != null) { mDecodeAggregator.expect(key, this); } else { @@ -293,7 +293,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod } @Override - public void onBecomeFirstExpected(final Request key) { + public void onBecomeFirstExpected(final RequestKey key) { if (!key.equals(mCurrKey)) { return; } @@ -310,7 +310,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod } @Override - public void onDecodeComplete(final Request key, final ReusableBitmap result) { + public void onDecodeComplete(final RequestKey key, final ReusableBitmap result) { if (mDecodeAggregator != null) { mDecodeAggregator.execute(key, new Runnable() { @Override @@ -328,7 +328,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod } } - private void onDecodeCompleteImpl(final Request key, final ReusableBitmap result) { + private void onDecodeCompleteImpl(final RequestKey key, final ReusableBitmap result) { if (key.equals(mCurrKey)) { setBitmap(result); } else { @@ -341,7 +341,7 @@ public class ExtendedBitmapDrawable extends Drawable implements DecodeTask.Decod } @Override - public void onDecodeCancel(final Request key) { + public void onDecodeCancel(final RequestKey key) { if (mDecodeAggregator != null) { mDecodeAggregator.forget(key); } |