修复直播列表少一个的问题

This commit is contained in:
zlzw 2024-10-22 10:20:42 +08:00
parent f75f0c0f0a
commit dc7b00c257

View File

@ -19,6 +19,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.LogUtils;
import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAParser;
@ -70,7 +71,12 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
if (position == 4) { if (position == 4) {
return HEAD; return HEAD;
} else{ } else{
LiveBean mode = mList.get(position>4?position-1:position); LiveBean mode;
if(mList.size()<4){
mode= mList.get(position);
}else {
mode = mList.get(position > 4 ? position - 1 : position);
}
if (TextUtils.equals(mode.getIs_week(), "1")) { if (TextUtils.equals(mode.getIs_week(), "1")) {
return WEEKLAYOUT; return WEEKLAYOUT;
} else { } else {
@ -138,7 +144,10 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override @Override
public int getItemCount() { public int getItemCount() {
return super.getItemCount(); if(mList.isEmpty()){
return 0;
}
return super.getItemCount()+1;
} }
class HeadVh extends RecyclerView.ViewHolder { class HeadVh extends RecyclerView.ViewHolder {