1717import androidx .appcompat .widget .AppCompatImageView ;
1818
1919public class AlmightyShapeImageView extends AppCompatImageView {
20- private Drawable mShapeDrawable ;
20+ private Drawable mShapeResource ;
2121 private Paint mShapePaint ;
2222
2323 public AlmightyShapeImageView (@ NonNull Context context ) {
@@ -32,7 +32,7 @@ public AlmightyShapeImageView(@NonNull Context context, @Nullable AttributeSet a
3232 super (context , attrs , defStyleAttr );
3333
3434 TypedArray a = context .obtainStyledAttributes (attrs , R .styleable .AlmightyShapeImageView );
35- mShapeDrawable = a .getDrawable (R .styleable .AlmightyShapeImageView_almighty_shape_resource );
35+ mShapeResource = a .getDrawable (R .styleable .AlmightyShapeImageView_almighty_shape_resource );
3636 a .recycle ();
3737 mShapePaint = new Paint ();
3838 mShapePaint .setColor (Color .WHITE );
@@ -43,7 +43,7 @@ public AlmightyShapeImageView(@NonNull Context context, @Nullable AttributeSet a
4343
4444 @ Override
4545 protected void onDraw (Canvas canvas ) {
46- if (mShapeDrawable != null ) {
46+ if (mShapeResource != null ) {
4747 mShapePaint .setXfermode (null );
4848 canvas .saveLayer (new RectF (0 , 0 , canvas .getWidth (), canvas .getHeight ()), mShapePaint , Canvas .ALL_SAVE_FLAG );
4949 drawShape (canvas );
@@ -64,23 +64,23 @@ private void drawShape(Canvas canvas) {
6464 int paddingBottom = getPaddingBottom ();
6565 mShapePaint .setXfermode (null );
6666 canvas .saveLayer (new RectF (0 , 0 , canvas .getWidth (), canvas .getHeight ()), mShapePaint , Canvas .ALL_SAVE_FLAG );
67- mShapeDrawable .setBounds (paddingLeft ,paddingTop ,width -paddingRight ,height -paddingBottom );
68- mShapeDrawable .draw (canvas );
67+ mShapeResource .setBounds (paddingLeft ,paddingTop ,width -paddingRight ,height -paddingBottom );
68+ mShapeResource .draw (canvas );
6969 mShapePaint .setXfermode (new PorterDuffXfermode (PorterDuff .Mode .SRC_IN ));
7070 canvas .saveLayer (new RectF (0 , 0 , canvas .getWidth (), canvas .getHeight ()), mShapePaint , Canvas .ALL_SAVE_FLAG );
7171 }
7272
7373 public Drawable getShapeDrawable () {
74- return mShapeDrawable ;
74+ return mShapeResource ;
7575 }
7676
77- public void setShapeDrawable (Drawable shapeDrawable ) {
78- this .mShapeDrawable = shapeDrawable ;
77+ public void setShapeResource (Drawable shapeResource ) {
78+ this .mShapeResource = shapeResource ;
7979 invalidate ();
8080 }
8181
82- public void setShapeDrawable (@ DrawableRes int shapeDrawableRes ) {
83- setShapeDrawable (getResources ().getDrawable (shapeDrawableRes ));
82+ public void setShapeResource (@ DrawableRes int shapeResourceRes ) {
83+ setShapeResource (getResources ().getDrawable (shapeResourceRes ));
8484 }
8585
8686
0 commit comments