package com.ubt.jimu.widgets; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.ColorFilter; import android.graphics.Shader; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.util.AttributeSet; import android.util.Log; import android.widget.ImageView; import com.ubt.jimu.R$styleable; @SuppressLint({"AppCompatCustomView"}) /* loaded from: classes2.dex */ public class RoundedImageView extends ImageView { public static final Shader.TileMode o = Shader.TileMode.CLAMP; private static final ImageView.ScaleType[] p = {ImageView.ScaleType.MATRIX, ImageView.ScaleType.FIT_XY, ImageView.ScaleType.FIT_START, ImageView.ScaleType.FIT_CENTER, ImageView.ScaleType.FIT_END, ImageView.ScaleType.CENTER, ImageView.ScaleType.CENTER_CROP, ImageView.ScaleType.CENTER_INSIDE}; private float a; private float b; private ColorStateList c; private boolean d; private boolean e; private Shader.TileMode f; private Shader.TileMode g; private ColorFilter h; private boolean i; private boolean j; private int k; private Drawable l; private Drawable m; private ImageView.ScaleType n; /* renamed from: com.ubt.jimu.widgets.RoundedImageView$1, reason: invalid class name */ static /* synthetic */ class AnonymousClass1 { static final /* synthetic */ int[] a = new int[ImageView.ScaleType.values().length]; static { try { a[ImageView.ScaleType.CENTER.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { a[ImageView.ScaleType.CENTER_CROP.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { a[ImageView.ScaleType.CENTER_INSIDE.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { a[ImageView.ScaleType.FIT_CENTER.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { a[ImageView.ScaleType.FIT_START.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } try { a[ImageView.ScaleType.FIT_END.ordinal()] = 6; } catch (NoSuchFieldError unused6) { } try { a[ImageView.ScaleType.FIT_XY.ordinal()] = 7; } catch (NoSuchFieldError unused7) { } } } public RoundedImageView(Context context) { super(context); this.a = 0.0f; this.b = 0.0f; this.c = ColorStateList.valueOf(-16777216); this.d = false; this.e = false; Shader.TileMode tileMode = o; this.f = tileMode; this.g = tileMode; this.h = null; this.i = false; this.j = false; } private static Shader.TileMode a(int i) { if (i == 0) { return Shader.TileMode.CLAMP; } if (i == 1) { return Shader.TileMode.REPEAT; } if (i != 2) { return null; } return Shader.TileMode.MIRROR; } private Drawable b() { Resources resources = getResources(); Drawable drawable = null; if (resources == null) { return null; } int i = this.k; if (i != 0) { try { drawable = resources.getDrawable(i); } catch (Exception e) { Log.w("RoundedImageView", "Unable to find resource: " + this.k, e); this.k = 0; } } return RoundedDrawable.b(drawable); } private void c() { a(this.l); } @Override // android.widget.ImageView, android.view.View protected void drawableStateChanged() { super.drawableStateChanged(); invalidate(); } public int getBorderColor() { return this.c.getDefaultColor(); } public ColorStateList getBorderColors() { return this.c; } public float getBorderWidth() { return this.b; } public float getCornerRadius() { return this.a; } @Override // android.widget.ImageView public ImageView.ScaleType getScaleType() { return this.n; } public Shader.TileMode getTileModeX() { return this.f; } public Shader.TileMode getTileModeY() { return this.g; } @Override // android.view.View public void setBackground(Drawable drawable) { setBackgroundDrawable(drawable); } @Override // android.view.View @Deprecated public void setBackgroundDrawable(Drawable drawable) { this.m = drawable; a(true); super.setBackgroundDrawable(this.m); } public void setBorderColor(int i) { setBorderColor(ColorStateList.valueOf(i)); } public void setBorderWidth(int i) { setBorderWidth(getResources().getDimension(i)); } @Override // android.widget.ImageView public void setColorFilter(ColorFilter colorFilter) { if (this.h != colorFilter) { this.h = colorFilter; this.i = true; this.j = true; a(); invalidate(); } } public void setCornerRadius(float f) { if (this.a == f) { return; } this.a = f; c(); a(false); invalidate(); } public void setCornerRadiusDimen(int i) { setCornerRadius(getResources().getDimension(i)); } @Override // android.widget.ImageView public void setImageBitmap(Bitmap bitmap) { this.k = 0; this.l = RoundedDrawable.a(bitmap); c(); super.setImageDrawable(this.l); } @Override // android.widget.ImageView public void setImageDrawable(Drawable drawable) { this.k = 0; this.l = RoundedDrawable.b(drawable); c(); super.setImageDrawable(this.l); } @Override // android.widget.ImageView public void setImageResource(int i) { if (this.k != i) { this.k = i; this.l = b(); c(); super.setImageDrawable(this.l); } } @Override // android.widget.ImageView public void setImageURI(Uri uri) { super.setImageURI(uri); setImageDrawable(getDrawable()); } public void setOval(boolean z) { this.d = z; c(); a(false); invalidate(); } @Override // android.widget.ImageView public void setScaleType(ImageView.ScaleType scaleType) { if (this.n != scaleType) { this.n = scaleType; switch (AnonymousClass1.a[scaleType.ordinal()]) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: super.setScaleType(ImageView.ScaleType.FIT_XY); break; default: super.setScaleType(scaleType); break; } c(); a(false); invalidate(); } } public void setTileModeX(Shader.TileMode tileMode) { if (this.f == tileMode) { return; } this.f = tileMode; c(); a(false); invalidate(); } public void setTileModeY(Shader.TileMode tileMode) { if (this.g == tileMode) { return; } this.g = tileMode; c(); a(false); invalidate(); } public void setBorderColor(ColorStateList colorStateList) { if (this.c.equals(colorStateList)) { return; } if (colorStateList == null) { colorStateList = ColorStateList.valueOf(-16777216); } this.c = colorStateList; c(); a(false); if (this.b > 0.0f) { invalidate(); } } public void setBorderWidth(float f) { if (this.b == f) { return; } this.b = f; c(); a(false); invalidate(); } private void a(boolean z) { if (this.e) { if (z) { this.m = RoundedDrawable.b(this.m); } a(this.m); } } private void a() { Drawable drawable = this.l; if (drawable == null || !this.j) { return; } this.l = drawable.mutate(); if (this.i) { this.l.setColorFilter(this.h); } } private void a(Drawable drawable) { if (drawable == null) { return; } if (drawable instanceof RoundedDrawable) { RoundedDrawable roundedDrawable = (RoundedDrawable) drawable; roundedDrawable.a(this.n); roundedDrawable.b(this.a); roundedDrawable.a(this.b); roundedDrawable.a(this.c); roundedDrawable.a(this.d); roundedDrawable.a(this.f); roundedDrawable.b(this.g); a(); return; } if (drawable instanceof LayerDrawable) { LayerDrawable layerDrawable = (LayerDrawable) drawable; int numberOfLayers = layerDrawable.getNumberOfLayers(); for (int i = 0; i < numberOfLayers; i++) { a(layerDrawable.getDrawable(i)); } } } public RoundedImageView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public RoundedImageView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.a = 0.0f; this.b = 0.0f; this.c = ColorStateList.valueOf(-16777216); this.d = false; this.e = false; Shader.TileMode tileMode = o; this.f = tileMode; this.g = tileMode; this.h = null; this.i = false; this.j = false; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.RoundedImageView, i, 0); int i2 = obtainStyledAttributes.getInt(0, -1); if (i2 >= 0) { setScaleType(p[i2]); } else { setScaleType(ImageView.ScaleType.FIT_CENTER); } this.a = obtainStyledAttributes.getDimensionPixelSize(3, -1); this.b = obtainStyledAttributes.getDimensionPixelSize(2, -1); if (this.a < 0.0f) { this.a = 0.0f; } if (this.b < 0.0f) { this.b = 0.0f; } this.c = obtainStyledAttributes.getColorStateList(1); if (this.c == null) { this.c = ColorStateList.valueOf(-16777216); } this.e = obtainStyledAttributes.getBoolean(4, false); this.d = obtainStyledAttributes.getBoolean(5, false); int i3 = obtainStyledAttributes.getInt(6, -2); if (i3 != -2) { setTileModeX(a(i3)); setTileModeY(a(i3)); } int i4 = obtainStyledAttributes.getInt(7, -2); if (i4 != -2) { setTileModeX(a(i4)); } int i5 = obtainStyledAttributes.getInt(8, -2); if (i5 != -2) { setTileModeY(a(i5)); } c(); a(true); obtainStyledAttributes.recycle(); } }