|
|
|
|
@ -4,7 +4,6 @@ import android.view.LayoutInflater; |
|
|
|
|
import android.view.ViewGroup; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
|
|
import com.fongmi.android.tv.bean.Style; |
|
|
|
|
import com.fongmi.android.tv.bean.Vod; |
|
|
|
|
@ -17,19 +16,14 @@ import com.fongmi.android.tv.ui.holder.VodListHolder; |
|
|
|
|
import com.fongmi.android.tv.ui.holder.VodOvalHolder; |
|
|
|
|
import com.fongmi.android.tv.ui.holder.VodRectHolder; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
public class VodAdapter extends RecyclerView.Adapter<BaseVodHolder> { |
|
|
|
|
public class VodAdapter extends BaseDiffAdapter<Vod, BaseVodHolder> { |
|
|
|
|
|
|
|
|
|
private final OnClickListener listener; |
|
|
|
|
private final List<Vod> mItems; |
|
|
|
|
private final Style style; |
|
|
|
|
private final int[] size; |
|
|
|
|
|
|
|
|
|
public VodAdapter(OnClickListener listener, Style style, int[] size) { |
|
|
|
|
this.listener = listener; |
|
|
|
|
this.mItems = new ArrayList<>(); |
|
|
|
|
this.style = style; |
|
|
|
|
this.size = size; |
|
|
|
|
} |
|
|
|
|
@ -45,22 +39,6 @@ public class VodAdapter extends RecyclerView.Adapter<BaseVodHolder> { |
|
|
|
|
return style; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addAll(List<Vod> items) { |
|
|
|
|
int position = mItems.size() + 1; |
|
|
|
|
mItems.addAll(items); |
|
|
|
|
notifyItemRangeInserted(position, items.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void clear() { |
|
|
|
|
mItems.clear(); |
|
|
|
|
notifyDataSetChanged(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getItemCount() { |
|
|
|
|
return mItems.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getItemViewType(int position) { |
|
|
|
|
return style.getViewType(); |
|
|
|
|
@ -68,7 +46,7 @@ public class VodAdapter extends RecyclerView.Adapter<BaseVodHolder> { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onBindViewHolder(@NonNull BaseVodHolder holder, int position) { |
|
|
|
|
holder.initView(mItems.get(position)); |
|
|
|
|
holder.initView(getItem(position)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|