Fix using useful bitmap
This commit is contained in:
1 parent
57acf0585d
commit
76e9dac1f6
3 files changed
+20
-8
No files matched your search
@@ -1,10 +1,10 @@
|
||||
package com.hippo.drawable;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.conaco.BitmapHolder;
|
||||
import com.hippo.conaco.Conaco;
|
||||
import com.hippo.conaco.Unikery;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -20,8 +20,10 @@ public class UnikeryDrawable extends WrapDrawable implements Unikery {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap, Conaco.Source source) {
|
||||
setDrawable(new BitmapDrawable(mView.getResources(), bitmap));
|
||||
public void setBitmap(BitmapHolder bitmapHolder, Conaco.Source source) {
|
||||
// TODO release sometime ?
|
||||
bitmapHolder.obtain();
|
||||
setDrawable(new BitmapDrawable(mView.getResources(), bitmapHolder.getBitmap()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@@ -10,6 +9,7 @@ import android.graphics.drawable.TransitionDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.hippo.conaco.BitmapHolder;
|
||||
import com.hippo.conaco.Conaco;
|
||||
import com.hippo.conaco.Unikery;
|
||||
|
||||
@@ -17,6 +17,8 @@ public class LoadImageView extends ImageView implements Unikery {
|
||||
|
||||
private int mTaskId = Unikery.INVAILD_ID;
|
||||
|
||||
private BitmapHolder mBitmapHolder;
|
||||
|
||||
public LoadImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -30,16 +32,24 @@ public class LoadImageView extends ImageView implements Unikery {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap, Conaco.Source source) {
|
||||
public void setBitmap(BitmapHolder bitmapHolder, Conaco.Source source) {
|
||||
BitmapHolder oldBitmapHolder = mBitmapHolder;
|
||||
|
||||
mBitmapHolder = bitmapHolder;
|
||||
bitmapHolder.obtain();
|
||||
if (source != Conaco.Source.MEMORY) {
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = new ColorDrawable(Color.TRANSPARENT);
|
||||
layers[1] = new BitmapDrawable(getContext().getResources(), bitmap);
|
||||
layers[1] = new BitmapDrawable(getContext().getResources(), bitmapHolder.getBitmap());
|
||||
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
|
||||
setImageDrawable(transitionDrawable);
|
||||
transitionDrawable.startTransition(300);
|
||||
} else {
|
||||
setImageBitmap(bitmap);
|
||||
setImageBitmap(bitmapHolder.getBitmap());
|
||||
}
|
||||
|
||||
if (oldBitmapHolder != null) {
|
||||
oldBitmapHolder.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user