package j2; import android.content.Context; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowManager; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import m2.j; /* loaded from: classes.dex */ public abstract class i extends j2.a { /* renamed from: f, reason: collision with root package name */ private static boolean f11024f; /* renamed from: g, reason: collision with root package name */ private static int f11025g = com.bumptech.glide.h.f4158a; /* renamed from: a, reason: collision with root package name */ protected final View f11026a; /* renamed from: b, reason: collision with root package name */ private final a f11027b; /* renamed from: c, reason: collision with root package name */ private View.OnAttachStateChangeListener f11028c; /* renamed from: d, reason: collision with root package name */ private boolean f11029d; /* renamed from: e, reason: collision with root package name */ private boolean f11030e; static final class a { /* renamed from: e, reason: collision with root package name */ static Integer f11031e; /* renamed from: a, reason: collision with root package name */ private final View f11032a; /* renamed from: b, reason: collision with root package name */ private final List f11033b = new ArrayList(); /* renamed from: c, reason: collision with root package name */ boolean f11034c; /* renamed from: d, reason: collision with root package name */ private ViewTreeObserverOnPreDrawListenerC0160a f11035d; /* renamed from: j2.i$a$a, reason: collision with other inner class name */ private static final class ViewTreeObserverOnPreDrawListenerC0160a implements ViewTreeObserver.OnPreDrawListener { /* renamed from: a, reason: collision with root package name */ private final WeakReference f11036a; ViewTreeObserverOnPreDrawListenerC0160a(a aVar) { this.f11036a = new WeakReference(aVar); } @Override // android.view.ViewTreeObserver.OnPreDrawListener public boolean onPreDraw() { if (Log.isLoggable("ViewTarget", 2)) { Log.v("ViewTarget", "OnGlobalLayoutListener called attachStateListener=" + this); } a aVar = (a) this.f11036a.get(); if (aVar == null) { return true; } aVar.a(); return true; } } a(View view) { this.f11032a = view; } private static int c(Context context) { if (f11031e == null) { Display defaultDisplay = ((WindowManager) j.d((WindowManager) context.getSystemService("window"))).getDefaultDisplay(); Point point = new Point(); defaultDisplay.getSize(point); f11031e = Integer.valueOf(Math.max(point.x, point.y)); } return f11031e.intValue(); } private int e(int i10, int i11, int i12) { int i13 = i11 - i12; if (i13 > 0) { return i13; } if (this.f11034c && this.f11032a.isLayoutRequested()) { return 0; } int i14 = i10 - i12; if (i14 > 0) { return i14; } if (this.f11032a.isLayoutRequested() || i11 != -2) { return 0; } if (Log.isLoggable("ViewTarget", 4)) { Log.i("ViewTarget", "Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions."); } return c(this.f11032a.getContext()); } private int f() { int paddingTop = this.f11032a.getPaddingTop() + this.f11032a.getPaddingBottom(); ViewGroup.LayoutParams layoutParams = this.f11032a.getLayoutParams(); return e(this.f11032a.getHeight(), layoutParams != null ? layoutParams.height : 0, paddingTop); } private int g() { int paddingLeft = this.f11032a.getPaddingLeft() + this.f11032a.getPaddingRight(); ViewGroup.LayoutParams layoutParams = this.f11032a.getLayoutParams(); return e(this.f11032a.getWidth(), layoutParams != null ? layoutParams.width : 0, paddingLeft); } private boolean h(int i10) { return i10 > 0 || i10 == Integer.MIN_VALUE; } private boolean i(int i10, int i11) { return h(i10) && h(i11); } private void j(int i10, int i11) { Iterator it = new ArrayList(this.f11033b).iterator(); while (it.hasNext()) { ((g) it.next()).c(i10, i11); } } void a() { if (this.f11033b.isEmpty()) { return; } int g10 = g(); int f10 = f(); if (i(g10, f10)) { j(g10, f10); b(); } } void b() { ViewTreeObserver viewTreeObserver = this.f11032a.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeOnPreDrawListener(this.f11035d); } this.f11035d = null; this.f11033b.clear(); } void d(g gVar) { int g10 = g(); int f10 = f(); if (i(g10, f10)) { gVar.c(g10, f10); return; } if (!this.f11033b.contains(gVar)) { this.f11033b.add(gVar); } if (this.f11035d == null) { ViewTreeObserver viewTreeObserver = this.f11032a.getViewTreeObserver(); ViewTreeObserverOnPreDrawListenerC0160a viewTreeObserverOnPreDrawListenerC0160a = new ViewTreeObserverOnPreDrawListenerC0160a(this); this.f11035d = viewTreeObserverOnPreDrawListenerC0160a; viewTreeObserver.addOnPreDrawListener(viewTreeObserverOnPreDrawListenerC0160a); } } void k(g gVar) { this.f11033b.remove(gVar); } } public i(View view) { this.f11026a = (View) j.d(view); this.f11027b = new a(view); } private Object i() { return this.f11026a.getTag(f11025g); } private void j() { View.OnAttachStateChangeListener onAttachStateChangeListener = this.f11028c; if (onAttachStateChangeListener == null || this.f11030e) { return; } this.f11026a.addOnAttachStateChangeListener(onAttachStateChangeListener); this.f11030e = true; } private void k() { View.OnAttachStateChangeListener onAttachStateChangeListener = this.f11028c; if (onAttachStateChangeListener == null || !this.f11030e) { return; } this.f11026a.removeOnAttachStateChangeListener(onAttachStateChangeListener); this.f11030e = false; } private void l(Object obj) { f11024f = true; this.f11026a.setTag(f11025g, obj); } @Override // j2.a, j2.h public void b(Drawable drawable) { super.b(drawable); j(); } @Override // j2.h public i2.c c() { Object i10 = i(); if (i10 == null) { return null; } if (i10 instanceof i2.c) { return (i2.c) i10; } throw new IllegalArgumentException("You must not call setTag() on a view Glide is targeting"); } @Override // j2.a, j2.h public void d(Drawable drawable) { super.d(drawable); this.f11027b.b(); if (this.f11029d) { return; } k(); } @Override // j2.h public void e(i2.c cVar) { l(cVar); } @Override // j2.h public void g(g gVar) { this.f11027b.d(gVar); } @Override // j2.h public void h(g gVar) { this.f11027b.k(gVar); } public String toString() { return "Target for: " + this.f11026a; } }