package com.bumptech.glide.request.target;

import android.graphics.drawable.Drawable;
import android.view.View;
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 f implements j {

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final e f5890a;

    @Nullable
    private View.OnAttachStateChangeListener attachStateListener;

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

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

    public f(View view) {
        this.f5891b = (View) n.checkNotNull(view);
        this.f5890a = new e(view);
    }

    @Nullable
    private Object getTag() {
        return this.f5891b.getTag(f5889d);
    }

    private void setTag(@Nullable Object obj) {
        this.f5891b.setTag(f5889d, obj);
    }

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

    @Override // n5.i
    public final void b() {
    }

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

    @Override // n5.i
    public final void d() {
    }

    @Override // com.bumptech.glide.request.target.j
    @Nullable
    public final 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 pass non-R.id ids to setTag(id)");
    }

    @Override // n5.i
    public final void onDestroy() {
    }

    @Override // com.bumptech.glide.request.target.j
    public final void onLoadCleared(@Nullable Drawable drawable) {
        this.f5890a.a();
        onResourceCleared(drawable);
        View.OnAttachStateChangeListener onAttachStateChangeListener = this.attachStateListener;
        if (onAttachStateChangeListener == null || !this.f5892c) {
            return;
        }
        this.f5891b.removeOnAttachStateChangeListener(onAttachStateChangeListener);
        this.f5892c = false;
    }

    @Override // com.bumptech.glide.request.target.j
    public abstract /* synthetic */ void onLoadFailed(@Nullable Drawable drawable);

    @Override // com.bumptech.glide.request.target.j
    public final void onLoadStarted(@Nullable Drawable drawable) {
        View.OnAttachStateChangeListener onAttachStateChangeListener = this.attachStateListener;
        if (onAttachStateChangeListener != null && !this.f5892c) {
            this.f5891b.addOnAttachStateChangeListener(onAttachStateChangeListener);
            this.f5892c = true;
        }
        onResourceLoading(drawable);
    }

    public abstract void onResourceCleared(@Nullable Drawable drawable);

    public void onResourceLoading(@Nullable Drawable drawable) {
    }

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

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

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