package ඓ.ῲ.K.㗗.㿎;

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 com.bumptech.glide.R$id;
import com.bumptech.glide.request.SingleRequest;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import ඓ.ῲ.K.㗗.AbstractC1189;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.㳳.C1841;

@Deprecated
/* renamed from: ඓ.ῲ.K.㗗.㿎.ᨨ  reason: contains not printable characters */
/* compiled from: ViewTarget */
public abstract class AbstractC1203<T extends View, Z> extends AbstractC1208<Z> {

    /* renamed from: ⁱ  reason: contains not printable characters */
    public static int f4770 = R$id.glide_custom_view_target_tag;

    /* renamed from: ʬ  reason: contains not printable characters */
    public final C1204 f4771;

    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean f4772;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final T f4773;

    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean f4774;

    /* renamed from: 㸾  reason: contains not printable characters */
    public View.OnAttachStateChangeListener f4775;

    public AbstractC1203(T t) {
        C1841.m4783(t, "Argument must not be null");
        this.f4773 = t;
        this.f4771 = new C1204(t);
    }

    public String toString() {
        StringBuilder r0 = C1293.m3416("Target for: ");
        r0.append(this.f4773);
        return r0.toString();
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1208, ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m3249(Drawable drawable) {
        View.OnAttachStateChangeListener onAttachStateChangeListener;
        super.m3260(drawable);
        this.f4771.m3257();
        if (!this.f4772 && (onAttachStateChangeListener = this.f4775) != null && this.f4774) {
            this.f4773.removeOnAttachStateChangeListener(onAttachStateChangeListener);
            this.f4774 = false;
        }
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: ῲ  reason: contains not printable characters */
    public void m3250(AbstractC1207 r5) {
        C1204 k = this.f4771;
        int r1 = k.m3254();
        int r2 = k.m3255();
        if (k.m3258(r1, r2)) {
            ((SingleRequest) r5).m1343(r1, r2);
            return;
        }
        if (!k.f4778.contains(r5)) {
            k.f4778.add(r5);
        }
        if (k.f4780 == null) {
            ViewTreeObserver viewTreeObserver = k.f4779.getViewTreeObserver();
            k.f4780 = new C1204.ViewTreeObserver$OnPreDrawListenerC1205(k);
            viewTreeObserver.addOnPreDrawListener(k.f4780);
        }
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1208, ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: K  reason: contains not printable characters */
    public void m3251(Drawable drawable) {
        super.m3263(drawable);
        View.OnAttachStateChangeListener onAttachStateChangeListener = this.f4775;
        if (onAttachStateChangeListener != null && !this.f4774) {
            this.f4773.addOnAttachStateChangeListener(onAttachStateChangeListener);
            this.f4774 = true;
        }
    }

    /* renamed from: ඓ.ῲ.K.㗗.㿎.ᨨ$K  reason: contains not printable characters */
    /* compiled from: ViewTarget */
    public static final class C1204 {

        /* renamed from: ඓ  reason: contains not printable characters */
        public static Integer f4776;

        /* renamed from: ʬ  reason: contains not printable characters */
        public boolean f4777;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final List<AbstractC1207> f4778 = new ArrayList();

        /* renamed from: K  reason: contains not printable characters */
        public final View f4779;

        /* renamed from: 㸾  reason: contains not printable characters */
        public ViewTreeObserver$OnPreDrawListenerC1205 f4780;

        /* renamed from: ඓ.ῲ.K.㗗.㿎.ᨨ$K$K  reason: contains not printable characters */
        /* compiled from: ViewTarget */
        public static final class ViewTreeObserver$OnPreDrawListenerC1205 implements ViewTreeObserver.OnPreDrawListener {

            /* renamed from: ῲ  reason: contains not printable characters */
            public final WeakReference<C1204> f4781;

            public ViewTreeObserver$OnPreDrawListenerC1205(C1204 k) {
                this.f4781 = new WeakReference<>(k);
            }

            public boolean onPreDraw() {
                if (Log.isLoggable("ViewTarget", 2)) {
                    Log.v("ViewTarget", "OnGlobalLayoutListener called attachStateListener=" + this);
                }
                C1204 k = this.f4781.get();
                if (k == null || k.f4778.isEmpty()) {
                    return true;
                }
                int r1 = k.m3254();
                int r2 = k.m3255();
                if (!k.m3258(r1, r2)) {
                    return true;
                }
                Iterator it2 = new ArrayList(k.f4778).iterator();
                while (it2.hasNext()) {
                    ((SingleRequest) it2.next()).m1343(r1, r2);
                }
                k.m3257();
                return true;
            }
        }

        public C1204(View view) {
            this.f4779 = view;
        }

        /* renamed from: ʬ  reason: contains not printable characters */
        public final int m3254() {
            int paddingRight = this.f4779.getPaddingRight() + this.f4779.getPaddingLeft();
            ViewGroup.LayoutParams layoutParams = this.f4779.getLayoutParams();
            return m3256(this.f4779.getWidth(), layoutParams != null ? layoutParams.width : 0, paddingRight);
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public final int m3255() {
            int paddingBottom = this.f4779.getPaddingBottom() + this.f4779.getPaddingTop();
            ViewGroup.LayoutParams layoutParams = this.f4779.getLayoutParams();
            return m3256(this.f4779.getHeight(), layoutParams != null ? layoutParams.height : 0, paddingBottom);
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m3257() {
            ViewTreeObserver viewTreeObserver = this.f4779.getViewTreeObserver();
            if (viewTreeObserver.isAlive()) {
                viewTreeObserver.removeOnPreDrawListener(this.f4780);
            }
            this.f4780 = null;
            this.f4778.clear();
        }

        /* renamed from: K  reason: contains not printable characters */
        public final boolean m3258(int i, int i2) {
            if (!(i > 0 || i == Integer.MIN_VALUE)) {
                return false;
            }
            return i2 > 0 || i2 == Integer.MIN_VALUE;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final int m3256(int i, int i2, int i3) {
            int i4 = i2 - i3;
            if (i4 > 0) {
                return i4;
            }
            if (this.f4777 && this.f4779.isLayoutRequested()) {
                return 0;
            }
            int i5 = i - i3;
            if (i5 > 0) {
                return i5;
            }
            if (this.f4779.isLayoutRequested() || i2 != -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.");
            }
            Context context = this.f4779.getContext();
            if (f4776 == null) {
                WindowManager windowManager = (WindowManager) context.getSystemService("window");
                C1841.m4783(windowManager, "Argument must not be null");
                Display defaultDisplay = windowManager.getDefaultDisplay();
                Point point = new Point();
                defaultDisplay.getSize(point);
                f4776 = Integer.valueOf(Math.max(point.x, point.y));
            }
            return f4776.intValue();
        }
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: K  reason: contains not printable characters */
    public void m3253(AbstractC1207 r2) {
        this.f4771.f4778.remove(r2);
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: ʬ  reason: contains not printable characters */
    public AbstractC1189 m3248() {
        Object tag = this.f4773.getTag(f4770);
        if (tag == null) {
            return null;
        }
        if (tag instanceof AbstractC1189) {
            return (AbstractC1189) tag;
        }
        throw new IllegalArgumentException("You must not call setTag() on a view Glide is targeting");
    }

    @Override // ඓ.ῲ.K.㗗.㿎.AbstractC1211
    /* renamed from: K  reason: contains not printable characters */
    public void m3252(AbstractC1189 r3) {
        this.f4773.setTag(f4770, r3);
    }
}
