package com.recyclelib.adapter; import android.content.Context; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; /* loaded from: classes.dex */ public abstract class MultiRecyclerAdapter extends RecyclerView.Adapter { protected Context mContext; protected LayoutInflater mInflater; protected List mList; protected static class MultiViewHolder extends RecyclerView.ViewHolder { private SparseArray a; private View b; public MultiViewHolder(View view) { super(view); this.a = new SparseArray<>(); this.b = view; } public K getView(int i) { K k = (K) this.a.get(i); if (k != null) { return k; } K k2 = (K) this.b.findViewById(i); this.a.put(i, k2); return k2; } } protected MultiRecyclerAdapter(Context context, List list) { this.mList = list == null ? new ArrayList<>() : list; this.mContext = context; this.mInflater = LayoutInflater.from(context); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public int getItemCount() { List list = this.mList; if (list == null) { return 0; } return list.size(); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public int getItemViewType(int i) { return getLayoutId(i); } public abstract int getLayoutId(int i); public void notifyChanged(List list) { if (this.mList == null) { this.mList = new ArrayList(); } this.mList.clear(); this.mList.addAll(list); notifyDataSetChanged(); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public MultiViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { return new MultiViewHolder(this.mInflater.inflate(i, viewGroup, false)); } protected MultiRecyclerAdapter(Context context) { this.mContext = context; this.mInflater = LayoutInflater.from(context); } }