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 BaseRecyclerAdapter extends RecyclerView.Adapter { protected Context mContext; protected LayoutInflater mInflater; protected List mList; protected static class BaseViewHolder extends RecyclerView.ViewHolder { private SparseArray a; private View b; public BaseViewHolder(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 BaseRecyclerAdapter(Context context, List list) { this.mList = list; if (this.mList == null) { this.mList = new ArrayList(); } this.mContext = context; this.mInflater = LayoutInflater.from(context); } public List getData() { if (this.mList == null) { this.mList = new ArrayList(); } return this.mList; } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public int getItemCount() { List list = this.mList; if (list == null) { return 0; } return list.size(); } public abstract int layoutId(); public void notifyChanged(List list) { if (list == null) { return; } if (this.mList == null) { this.mList = new ArrayList(); } this.mList.clear(); this.mList.addAll(list); notifyDataSetChanged(); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public BaseViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { return new BaseViewHolder(this.mInflater.inflate(layoutId(), viewGroup, false)); } }