make BitmapDrawable functional

This commit is contained in:
Julian Winkler
2023-08-06 14:27:30 +02:00
parent 8c1e98b09c
commit c10504c089
5 changed files with 58 additions and 9 deletions

View File

@@ -2,7 +2,21 @@ package android.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
public class BitmapDrawable extends Drawable {
public BitmapDrawable(Resources res, Bitmap bitmap) {}
private Bitmap bitmap;
public BitmapDrawable(Resources res, Bitmap bitmap) {
this.bitmap = bitmap;
}
@Override
public void draw(Canvas canvas) {
canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getWidth()), new RectF(getBounds()), null);
}
}

View File

@@ -1,5 +1,33 @@
package android.graphics.drawable;
public class Drawable {
import android.graphics.Canvas;
import android.graphics.Rect;
public abstract class Drawable {
private Rect mBounds = new Rect();
public int getChangingConfigurations() {
return 0;
}
public void setChangingConfigurations(int bitmap) {}
public ConstantState getConstantState() {
return new ConstantState();
}
public class ConstantState {
}
public void setBounds(int left, int top, int right, int bottom) {
mBounds.set(left, top, right, bottom);
}
public final Rect getBounds() {
return mBounds;
}
public abstract void draw(Canvas canvas);
}