1.修改Baner尺寸 之前有代码强行限制了高度

This commit is contained in:
ningwenqiang 2024-11-05 18:25:25 +08:00
parent 64ef9b27ae
commit 96f158b029

View File

@ -55,7 +55,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
private Context context;
private int Height;
private int getWeekIntIndex = 0;
private boolean showBaner =true;
private boolean showBaner = true;
public void setShowBaner(boolean showBaner) {
// this.showBaner = showBaner;
@ -66,7 +66,6 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
this.context = context;
this.Height = h;
mHeadView = mInflater.inflate(R.layout.item_main_home_live_head, null, false);
mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(85)));
}
public View getHeadView() {
@ -75,23 +74,23 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override
public int getItemViewType(int position) {
if (!showBaner){
if (!showBaner) {
if (position % 2 == 1) {
return RIGHT;
}else {
} else {
return LEFT;
}
}
if (position == 4) {
return HEAD;
} else{
} else {
LiveBean mode;
if(mList.size()<4){
if(position>=mList.size()){
if (mList.size() < 4) {
if (position >= mList.size()) {
return HEAD;
}
mode= mList.get(position);
}else {
mode = mList.get(position);
} else {
mode = mList.get(position > 4 ? position - 1 : position);
}
if (TextUtils.equals(mode.getIs_week(), "1")) {
@ -143,7 +142,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
int nowPosition = position>4?position-1:position;
int nowPosition = position > 4 ? position - 1 : position;
if (vh instanceof MainHomeLiveWeekItemViewHolder) {
((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(nowPosition), nowPosition, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() {
@Override
@ -169,10 +168,10 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
public int getItemCount() {
if (!showBaner)
return super.getItemCount();
if(mList.isEmpty()){
if (mList.isEmpty()) {
return 0;
}
return super.getItemCount()+1;
return super.getItemCount() + 1;
}
class HeadVh extends RecyclerView.ViewHolder {