package androidx.leanback.widget;

import android.os.Parcelable;
import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import defpackage.ol5;

/* JADX INFO: loaded from: classes.dex */
class l implements RecyclerView.x {
    public final /* synthetic */ m a;

    public l(m mVar) {
        this.a = mVar;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.x
    public final void a(RecyclerView.ag agVar) {
        GridLayoutManager gridLayoutManager = this.a.a;
        gridLayoutManager.getClass();
        int absoluteAdapterPosition = agVar.getAbsoluteAdapterPosition();
        if (absoluteAdapterPosition != -1) {
            t0 t0Var = gridLayoutManager.as;
            View view = agVar.itemView;
            int i = t0Var.a;
            if (i == 1) {
                ol5 ol5Var = t0Var.c;
                if (ol5Var == null || ol5Var.size() == 0) {
                    return;
                }
                t0Var.c.remove(Integer.toString(absoluteAdapterPosition));
                return;
            }
            if ((i == 2 || i == 3) && t0Var.c != null) {
                String string = Integer.toString(absoluteAdapterPosition);
                SparseArray<Parcelable> sparseArray = new SparseArray<>();
                view.saveHierarchyState(sparseArray);
                t0Var.c.put(string, sparseArray);
            }
        }
    }
}
