101 lines
2.8 KiB
Java
101 lines
2.8 KiB
Java
package com.twitter.sdk.android.tweetui.internal;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.widget.ImageView;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class OverlayImageView extends ImageView {
|
|
Overlay a;
|
|
|
|
public OverlayImageView(Context context) {
|
|
super(context);
|
|
this.a = new Overlay(null);
|
|
}
|
|
|
|
@Override // android.widget.ImageView, android.view.View
|
|
protected void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
this.a.a(getDrawableState());
|
|
}
|
|
|
|
@Override // android.widget.ImageView, android.view.View, android.graphics.drawable.Drawable.Callback
|
|
public void invalidateDrawable(Drawable drawable) {
|
|
if (drawable == this.a.a) {
|
|
invalidate();
|
|
} else {
|
|
super.invalidateDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.ImageView, android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
super.onDraw(canvas);
|
|
this.a.a(canvas);
|
|
}
|
|
|
|
@Override // android.widget.ImageView, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
this.a.a(getMeasuredWidth(), getMeasuredHeight());
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
this.a.a(i, i2);
|
|
}
|
|
|
|
public void setOverlayDrawable(Drawable drawable) {
|
|
Overlay overlay = this.a;
|
|
if (drawable != overlay.a) {
|
|
overlay.a(this);
|
|
if (drawable != null) {
|
|
drawable.setCallback(this);
|
|
}
|
|
this.a = new Overlay(drawable);
|
|
this.a.a(getDrawableState());
|
|
requestLayout();
|
|
}
|
|
}
|
|
|
|
protected static class Overlay {
|
|
final Drawable a;
|
|
|
|
Overlay(Drawable drawable) {
|
|
this.a = drawable;
|
|
}
|
|
|
|
protected void a(ImageView imageView) {
|
|
Drawable drawable = this.a;
|
|
if (drawable != null) {
|
|
drawable.setCallback(null);
|
|
imageView.unscheduleDrawable(this.a);
|
|
}
|
|
}
|
|
|
|
protected void a(int i, int i2) {
|
|
Drawable drawable = this.a;
|
|
if (drawable != null) {
|
|
drawable.setBounds(0, 0, i, i2);
|
|
}
|
|
}
|
|
|
|
protected void a(int[] iArr) {
|
|
Drawable drawable = this.a;
|
|
if (drawable == null || !drawable.isStateful()) {
|
|
return;
|
|
}
|
|
this.a.setState(iArr);
|
|
}
|
|
|
|
protected void a(Canvas canvas) {
|
|
Drawable drawable = this.a;
|
|
if (drawable != null) {
|
|
drawable.draw(canvas);
|
|
}
|
|
}
|
|
}
|
|
}
|