You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
BitmapDrawable: prevent garbage collection while in use
This commit is contained in:
@@ -36,7 +36,8 @@ public class BitmapDrawable extends Drawable {
|
|||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
final TypedArray a = r.obtainAttributes(attrs, R.styleable.BitmapDrawable);
|
final TypedArray a = r.obtainAttributes(attrs, R.styleable.BitmapDrawable);
|
||||||
if (a.hasValue(R.styleable.BitmapDrawable_src)) {
|
if (a.hasValue(R.styleable.BitmapDrawable_src)) {
|
||||||
paintable = a.getDrawable(R.styleable.BitmapDrawable_src).paintable;
|
bitmap = ((BitmapDrawable)a.getDrawable(R.styleable.BitmapDrawable_src)).bitmap;
|
||||||
|
paintable = bitmap.getTexture();
|
||||||
}
|
}
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -61,12 +60,10 @@ public class ImageView extends View {
|
|||||||
|
|
||||||
public void setImageDrawable(Drawable drawable) {
|
public void setImageDrawable(Drawable drawable) {
|
||||||
this.drawable = drawable;
|
this.drawable = drawable;
|
||||||
if (drawable instanceof BitmapDrawable) {
|
if (drawable != null) {
|
||||||
setImageBitmap(((BitmapDrawable) drawable).getBitmap());
|
|
||||||
} else if (drawable != null && drawable.paintable != 0) {
|
|
||||||
drawable.setCallback(this);
|
drawable.setCallback(this);
|
||||||
native_setDrawable(widget, drawable.paintable);
|
|
||||||
}
|
}
|
||||||
|
native_setDrawable(widget, drawable != null ? drawable.paintable : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImageMatrix(Matrix matrix) {}
|
public void setImageMatrix(Matrix matrix) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user