package com.bumptech.glide.request.target;

import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.o;
import t5.n;

/* JADX INFO: loaded from: classes.dex */
public abstract class m extends a {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final int f5896e = o.glide_custom_view_target_tag;

    @Nullable
    private View.OnAttachStateChangeListener attachStateListener;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final View f5897b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final l f5898c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f5899d;

    public m(View view) {
        this.f5897b = (View) n.checkNotNull(view);
        this.f5898c = new l(view);
    }

    @Nullable
    private Object getTag() {
        return this.f5897b.getTag(f5896e);
    }

    private void setTag(@Nullable Object obj) {
        this.f5897b.setTag(f5896e, obj);
    }

    @Override // com.bumptech.glide.request.target.j
    public final void a(i iVar) {
        this.f5898c.f5895b.remove(iVar);
    }

    @Override // com.bumptech.glide.request.target.j
    public final void c(i iVar) {
        this.f5898c.b(iVar);
    }

    @Override // com.bumptech.glide.request.target.a, com.bumptech.glide.request.target.j
    @Nullable
    public q5.c getRequest() {
        Object tag = getTag();
        if (tag == null) {
            return null;
        }
        if (tag instanceof q5.c) {
            return (q5.c) tag;
        }
        throw new IllegalArgumentException("You must not call setTag() on a view Glide is targeting");
    }

    @Override // com.bumptech.glide.request.target.a, com.bumptech.glide.request.target.j
    @CallSuper
    public void onLoadCleared(@Nullable Drawable drawable) {
        super.onLoadCleared(drawable);
        this.f5898c.a();
        View.OnAttachStateChangeListener onAttachStateChangeListener = this.attachStateListener;
        if (onAttachStateChangeListener == null || !this.f5899d) {
            return;
        }
        this.f5897b.removeOnAttachStateChangeListener(onAttachStateChangeListener);
        this.f5899d = false;
    }

    @Override // com.bumptech.glide.request.target.a, com.bumptech.glide.request.target.j
    @CallSuper
    public void onLoadStarted(@Nullable Drawable drawable) {
        super.onLoadStarted(drawable);
        View.OnAttachStateChangeListener onAttachStateChangeListener = this.attachStateListener;
        if (onAttachStateChangeListener == null || this.f5899d) {
            return;
        }
        this.f5897b.addOnAttachStateChangeListener(onAttachStateChangeListener);
        this.f5899d = true;
    }

    @Override // com.bumptech.glide.request.target.a, com.bumptech.glide.request.target.j
    public abstract /* synthetic */ void onResourceReady(@NonNull Object obj, @Nullable r5.c cVar);

    @Override // com.bumptech.glide.request.target.a, com.bumptech.glide.request.target.j
    public void setRequest(@Nullable q5.c cVar) {
        setTag(cVar);
    }

    public final String toString() {
        return "Target for: " + this.f5897b;
    }
}
