package ඓ.ʬ.K.K.K;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import ඓ.ʬ.K.K.K.C0622;
import ඓ.ʬ.K.K.K.ඓ.C0611;
import ඓ.ʬ.K.K.K.㴹.C0621;

/* renamed from: ඓ.ʬ.K.K.K.ῲ  reason: contains not printable characters */
/* compiled from: BaseQuickAdapter */
public abstract class AbstractC0612<T, K extends C0622> extends RecyclerView.AbstractC0246<K> {

    /* renamed from: ʬ  reason: contains not printable characters */
    public boolean f3582 = false;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public LinearLayout f3583;

    /* renamed from: Ԛ  reason: contains not printable characters */
    public int f3584;

    /* renamed from: ؿ  reason: contains not printable characters */
    public FrameLayout f3585;

    /* renamed from: ݜ  reason: contains not printable characters */
    public boolean f3586;

    /* renamed from: ඓ  reason: contains not printable characters */
    public AbstractC0618 f3587;

    /* renamed from: ᆯ  reason: contains not printable characters */
    public int f3588 = 1;

    /* renamed from: ᑓ  reason: contains not printable characters */
    public boolean f3589;

    /* renamed from: ᓆ  reason: contains not printable characters */
    public List<T> f3590 = new ArrayList();

    /* renamed from: ᓣ  reason: contains not printable characters */
    public boolean f3591 = true;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public int f3592 = -1;

    /* renamed from: ᝁ  reason: contains not printable characters */
    public AbstractC0616 f3593;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public Interpolator f3594 = new LinearInterpolator();

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean f3595 = false;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public boolean f3596 = true;

    /* renamed from: K  reason: contains not printable characters */
    public boolean f3597 = false;

    /* renamed from: ゎ  reason: contains not printable characters */
    public boolean f3598;

    /* renamed from: ト  reason: contains not printable characters */
    public int f3599 = 1;

    /* renamed from: 㑃  reason: contains not printable characters */
    public C0611 f3600;

    /* renamed from: 㗗  reason: contains not printable characters */
    public LinearLayout f3601;

    /* renamed from: 㗽  reason: contains not printable characters */
    public boolean f3602;

    /* renamed from: 㮔  reason: contains not printable characters */
    public boolean f3603;

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f3604 = 300;

    /* renamed from: 㴪  reason: contains not printable characters */
    public RecyclerView f3605;

    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean f3606 = false;

    /* renamed from: 㶋  reason: contains not printable characters */
    public LayoutInflater f3607;

    /* renamed from: 㸾  reason: contains not printable characters */
    public C0621 f3608 = new C0621();

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f3609 = false;

    /* renamed from: 䀟  reason: contains not printable characters */
    public Context f3610;

    /* renamed from: 䁗  reason: contains not printable characters */
    public C0611 f3611 = new C0611();

    /* renamed from: 䃖  reason: contains not printable characters */
    public boolean f3612;

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$ʬ  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0613 {
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$ඓ  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0614 {
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$ῲ  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0615 {
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$ⁱ  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0616 {
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$K  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public class C0617 extends GridLayoutManager.AbstractC0223 {

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ GridLayoutManager f3613;

        public C0617(GridLayoutManager gridLayoutManager) {
            this.f3613 = gridLayoutManager;
        }

        @Override // androidx.recyclerview.widget.GridLayoutManager.AbstractC0223
        /* renamed from: K  reason: contains not printable characters */
        public int m2070(int i) {
            int itemViewType = AbstractC0612.this.getItemViewType(i);
            if (itemViewType == 273 && AbstractC0612.this.m2065()) {
                return 1;
            }
            if (itemViewType == 819 && AbstractC0612.this.m2047()) {
                return 1;
            }
            AbstractC0612 r1 = AbstractC0612.this;
            AbstractC0616 r2 = r1.f3593;
            if (r1.m2044(itemViewType)) {
                return this.f3613.m772();
            }
            return 1;
        }
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$㴹  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0618 {
    }

    /* renamed from: ඓ.ʬ.K.K.K.ῲ$㸾  reason: contains not printable characters */
    /* compiled from: BaseQuickAdapter */
    public interface AbstractC0619 {
    }

    public AbstractC0612(int i) {
        if (i != 0) {
            this.f3584 = i;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0246
    public int getItemCount() {
        int i = 1;
        if (m2053() == 1) {
            if (this.f3602 && m2043() != 0) {
                i = 2;
            }
            if (!this.f3586 || m2048() == 0) {
                return i;
            }
            return i + 1;
        }
        return m2067() + m2048() + this.f3590.size() + m2043();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0246
    public long getItemId(int i) {
        return (long) i;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0246
    public int getItemViewType(int i) {
        if (m2053() == 1) {
            boolean z = this.f3602 && m2043() != 0;
            if (i != 0) {
                if (i != 1) {
                    if (i != 2) {
                        return 1365;
                    }
                    return 819;
                } else if (z) {
                    return 1365;
                } else {
                    return 819;
                }
            } else if (z) {
                return 273;
            } else {
                return 1365;
            }
        } else {
            int r0 = m2043();
            if (i < r0) {
                return 273;
            }
            int i2 = i - r0;
            int size = this.f3590.size();
            if (i2 < size) {
                return m2054(i2);
            }
            if (i2 - size < m2048()) {
                return 819;
            }
            return 546;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0246
    public void onAttachedToRecyclerView(RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
        RecyclerView.AbstractC0254 layoutManager = recyclerView.getLayoutManager();
        if (layoutManager instanceof GridLayoutManager) {
            GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
            gridLayoutManager.m783(new C0617(gridLayoutManager));
        }
    }

    public void setOnItemChildClickListener(AbstractC0615 r1) {
    }

    public void setOnItemChildLongClickListener(AbstractC0613 r1) {
    }

    public void setOnItemClickListener(AbstractC0619 r1) {
    }

    public void setOnItemLongClickListener(AbstractC0614 r1) {
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public int m2043() {
        LinearLayout linearLayout = this.f3583;
        return (linearLayout == null || linearLayout.getChildCount() == 0) ? 0 : 1;
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public boolean m2044(int i) {
        return i == 1365 || i == 273 || i == 819 || i == 546;
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public int m2045() {
        return m2048() + this.f3590.size() + m2043();
    }

    /* renamed from: ᕣ  reason: contains not printable characters */
    public boolean m2046() {
        return this.f3589;
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public boolean m2047() {
        return this.f3612;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public T m2049(int i) {
        if (i < this.f3590.size()) {
            return this.f3590.get(i);
        }
        return null;
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final void m2052() {
    }

    /* renamed from: K  reason: contains not printable characters */
    public void onBindViewHolder(K k, int i) {
        if (m2046()) {
            m2064();
        }
        if (m2067() != 0 && i >= getItemCount() - this.f3588) {
            C0621 k2 = this.f3608;
            if (k2.f3617 == 1) {
                k2.f3617 = 2;
                if (!this.f3582) {
                    this.f3582 = true;
                    if (m2068() != null) {
                        m2068().post(new RunnableC0610(this));
                    } else {
                        throw null;
                    }
                }
            }
        }
        int itemViewType = k.getItemViewType();
        if (itemViewType == 0) {
            m2063(k, m2049(i - m2043()));
        } else if (itemViewType == 273) {
        } else {
            if (itemViewType == 546) {
                C0621 k3 = this.f3608;
                int i2 = k3.f3617;
                if (i2 == 1) {
                    k3.m2071(k, false);
                    k3.m2073(k, false);
                    k3.m2075(k, false);
                } else if (i2 == 2) {
                    k3.m2071(k, true);
                    k3.m2073(k, false);
                    k3.m2075(k, false);
                } else if (i2 == 3) {
                    k3.m2071(k, false);
                    k3.m2073(k, true);
                    k3.m2075(k, false);
                } else if (i2 == 4) {
                    k3.m2071(k, false);
                    k3.m2073(k, false);
                    k3.m2075(k, true);
                }
            } else if (itemViewType != 819 && itemViewType != 1365) {
                m2063(k, m2049(i - m2043()));
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public abstract void m2063(K k, T t);

    /* renamed from: 㑃  reason: contains not printable characters */
    public boolean m2064() {
        return this.f3598;
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public boolean m2065() {
        return this.f3603;
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public final void m2066() {
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public int m2067() {
        return 0;
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public RecyclerView m2068() {
        return this.f3605;
    }

    /* renamed from: 䁗  reason: contains not printable characters */
    public void m2069() {
        C0621 k = this.f3608;
        if (k.f3617 != 2) {
            k.f3617 = 1;
            notifyItemChanged(m2045());
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0246
    public K onCreateViewHolder(ViewGroup viewGroup, int i) {
        K k;
        this.f3610 = viewGroup.getContext();
        this.f3607 = LayoutInflater.from(this.f3610);
        if (i == 273) {
            k = m2056(this.f3583);
        } else if (i == 546) {
            k = m2056(m2055(this.f3608.m2074(), viewGroup));
            k.itemView.setOnClickListener(new View$OnClickListenerC0620(this));
        } else if (i == 819) {
            k = m2056(this.f3601);
        } else if (i != 1365) {
            k = m2050(viewGroup, i);
            if (!(k == null || k.itemView == null)) {
                m2066();
                m2052();
            }
        } else {
            k = m2056(this.f3585);
        }
        k.m2079(this);
        return k;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public int m2048() {
        LinearLayout linearLayout = this.f3601;
        return (linearLayout == null || linearLayout.getChildCount() == 0) ? 0 : 1;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public K m2050(ViewGroup viewGroup, int i) {
        return m2057(viewGroup, this.f3584);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m2051(View view) {
        boolean z;
        int i = 0;
        if (this.f3585 == null) {
            this.f3585 = new FrameLayout(view.getContext());
            RecyclerView.C0235 r0 = new RecyclerView.C0235(-1, -1);
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            if (layoutParams != null) {
                ((ViewGroup.MarginLayoutParams) r0).width = layoutParams.width;
                ((ViewGroup.MarginLayoutParams) r0).height = layoutParams.height;
            }
            this.f3585.setLayoutParams(r0);
            z = true;
        } else {
            z = false;
        }
        this.f3585.removeAllViews();
        this.f3585.addView(view);
        this.f3591 = true;
        if (z && m2053() == 1) {
            if (this.f3602 && m2043() != 0) {
                i = 1;
            }
            notifyItemInserted(i);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2060(List<T> list) {
        if (list == null) {
            list = new ArrayList<>();
        }
        this.f3590 = list;
        this.f3592 = -1;
        notifyDataSetChanged();
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m2053() {
        FrameLayout frameLayout = this.f3585;
        if (frameLayout == null || frameLayout.getChildCount() == 0 || !this.f3591 || this.f3590.size() != 0) {
            return 0;
        }
        return 1;
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m2054(int i) {
        return super.getItemViewType(i);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void onViewAttachedToWindow(K k) {
        super.onViewAttachedToWindow(k);
        int itemViewType = k.getItemViewType();
        if (itemViewType == 1365 || itemViewType == 273 || itemViewType == 819 || itemViewType == 546) {
            m2059((RecyclerView.AbstractC0269) k);
        } else if (this.f3609) {
            if (!this.f3596 || k.getLayoutPosition() > this.f3592) {
                C0611 k2 = this.f3600;
                if (k2 == null) {
                    k2 = this.f3611;
                }
                Animator[] animatorArr = {ObjectAnimator.ofFloat(k.itemView, "alpha", k2.f3581, 1.0f)};
                for (Animator animator : animatorArr) {
                    k.getLayoutPosition();
                    m2058(animator);
                }
                this.f3592 = k.getLayoutPosition();
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2059(RecyclerView.AbstractC0269 r2) {
        if (r2.itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.C0272) {
            ((StaggeredGridLayoutManager.C0272) r2.itemView.getLayoutParams()).f1586 = true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public K m2057(ViewGroup viewGroup, int i) {
        return m2056(m2055(i, viewGroup));
    }

    /* JADX WARNING: Code restructure failed: missing block: B:12:0x002d, code lost:
        r0 = r6;
     */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0051  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0057 A[SYNTHETIC, Splitter:B:24:0x0057] */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00b8  */
    /* JADX WARNING: Removed duplicated region for block: B:54:? A[RETURN, SYNTHETIC] */
    /* renamed from: K  reason: contains not printable characters */
    public K m2056(View view) {
        T t;
        Class cls;
        Class<?> cls2 = getClass();
        Class cls3 = null;
        while (true) {
            int i = 0;
            if (cls3 == null && cls2 != null) {
                Type genericSuperclass = cls2.getGenericSuperclass();
                if (genericSuperclass instanceof ParameterizedType) {
                    Type[] actualTypeArguments = ((ParameterizedType) genericSuperclass).getActualTypeArguments();
                    int length = actualTypeArguments.length;
                    while (true) {
                        if (i >= length) {
                            break;
                        }
                        Type type = actualTypeArguments[i];
                        if (type instanceof Class) {
                            cls = (Class) type;
                            if (C0622.class.isAssignableFrom(cls)) {
                                break;
                            }
                            i++;
                        } else {
                            if (type instanceof ParameterizedType) {
                                Type rawType = ((ParameterizedType) type).getRawType();
                                if (rawType instanceof Class) {
                                    cls = (Class) rawType;
                                    if (C0622.class.isAssignableFrom(cls)) {
                                        break;
                                    }
                                } else {
                                    continue;
                                }
                            } else {
                                continue;
                            }
                            i++;
                        }
                    }
                }
                cls3 = null;
                cls2 = cls2.getSuperclass();
            } else if (cls3 != null) {
                t = (K) new C0622(view);
            } else {
                try {
                    if (!cls3.isMemberClass() || Modifier.isStatic(cls3.getModifiers())) {
                        Constructor<T> declaredConstructor = cls3.getDeclaredConstructor(View.class);
                        declaredConstructor.setAccessible(true);
                        t = declaredConstructor.newInstance(view);
                    } else {
                        Constructor<T> declaredConstructor2 = cls3.getDeclaredConstructor(getClass(), View.class);
                        declaredConstructor2.setAccessible(true);
                        t = declaredConstructor2.newInstance(this, view);
                    }
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                    t = (K) null;
                    if (t != null) {
                    }
                } catch (IllegalAccessException e2) {
                    e2.printStackTrace();
                    t = (K) null;
                    if (t != null) {
                    }
                } catch (InstantiationException e3) {
                    e3.printStackTrace();
                    t = (K) null;
                    if (t != null) {
                    }
                } catch (InvocationTargetException e4) {
                    e4.printStackTrace();
                    t = (K) null;
                    if (t != null) {
                    }
                }
            }
        }
        if (cls3 != null) {
        }
        return t != null ? (K) t : (K) new C0622(view);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2058(Animator animator) {
        animator.setDuration((long) this.f3604).start();
        animator.setInterpolator(this.f3594);
    }

    /* renamed from: K  reason: contains not printable characters */
    public View m2055(int i, ViewGroup viewGroup) {
        return this.f3607.inflate(i, viewGroup, false);
    }
}
