From 6a78563d32cb2247bd35b9b9bcbc97cdfb46e3d8 Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Thu, 10 Oct 2024 15:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E7=9B=B4=E6=92=AD=E9=97=B4?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/adapter/MainHomeLiveAdapter.java | 34 +++++++++++-------- .../adapter/MainHomeRemFollLiveAdapter.java | 8 ++--- .../views/MainHomeLiveItemViewHolder.java | 20 +++++------ .../main/views/MainHomeLiveViewHolder.java | 10 +++--- .../SearchRecommendBodyItemViewHolder.java | 12 +++---- 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java index adaa49af4..c54acd668 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java @@ -32,6 +32,7 @@ import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.bean.LiveBean; import com.yunbao.main.R; import com.yunbao.main.views.MainHomeLiveItemViewHolder; +import com.yunbao.main.views.MainHomeLiveWeekItemViewHolder; import java.util.List; @@ -66,12 +67,16 @@ public class MainHomeLiveAdapter extends RefreshAdapter { @Override public int getItemViewType(int position) { - LiveBean mode = mList.get(position); - if (TextUtils.equals(mode.getIs_week(), "1")) { - return WEEKLAYOUT; - } else { - if (position % 2 == 0) { - return RIGHT; + if (position == 4) { + return HEAD; + } else{ + LiveBean mode = mList.get(position>4?position-1:position); + if (TextUtils.equals(mode.getIs_week(), "1")) { + return WEEKLAYOUT; + } else { + if (position % 2 == 0) { + return RIGHT; + } } } return LEFT; @@ -90,8 +95,8 @@ public class MainHomeLiveAdapter extends RefreshAdapter { HeadVh headVh = new HeadVh(mHeadView); headVh.setIsRecyclable(false); return headVh; - /* case WEEKLAYOUT: - return new MainHomeLiveWeekItemViewHolder(mInflater.inflate(R.layout.item_main_home_lives, parent, false));*/ + case WEEKLAYOUT: + return new MainHomeLiveWeekItemViewHolder(mInflater.inflate(R.layout.item_main_home_lives, parent, false)); default: return new MainHomeLiveItemViewHolder(mInflater.inflate(R.layout.item_main_home_lives, parent, false)); } @@ -100,17 +105,18 @@ public class MainHomeLiveAdapter extends RefreshAdapter { @Override public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) { //局部刷新周星榜svaga - /* if (holder instanceof MainHomeLiveWeekItemViewHolder) { + if (holder instanceof MainHomeLiveWeekItemViewHolder) { ((MainHomeLiveWeekItemViewHolder) holder).upSvga(); - }*/ + } super.onViewDetachedFromWindow(holder); } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { - /* if (vh instanceof MainHomeLiveWeekItemViewHolder) { - ((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(position), position, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() { + int nowPosition = position>4?position-1:position; + if (vh instanceof MainHomeLiveWeekItemViewHolder) { + ((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(nowPosition), nowPosition, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() { @Override public void onItemClick(LiveBean bean, int position) { if (mOnItemClickListener != null) { @@ -118,8 +124,8 @@ public class MainHomeLiveAdapter extends RefreshAdapter { } } }); - } else */if (vh instanceof MainHomeLiveItemViewHolder) { - ((MainHomeLiveItemViewHolder) vh).loadViewDate(mList.get(position), position, Height, new MainHomeLiveItemViewHolder.OnItemClickListener() { + } else if (vh instanceof MainHomeLiveItemViewHolder) { + ((MainHomeLiveItemViewHolder) vh).loadViewDate(mList.get(nowPosition), nowPosition, Height, new MainHomeLiveItemViewHolder.OnItemClickListener() { @Override public void onItemClick(LiveBean bean, int position) { if (mOnItemClickListener != null) { diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java index 89f92886c..62fe73882 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java @@ -154,7 +154,7 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { } else { viewBg.setVisibility(View.GONE); } - /*if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && Height <= 1920) { + if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && Height <= 1920) { Log.e("t1", position + "嗯" + Height + "111啊" + bean.getContent_pic_size_two()); Picasso.with(mContext) @@ -165,7 +165,7 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { Picasso.with(mContext) .load(bean.getContent_pic_size_three()) .into(live_type); - }*/ + } live_info_view.setVisibility(View.GONE); @@ -204,7 +204,7 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { mNum.setText(formatBigNum.formatBigNum(bean.getHot_num())); views.setVisibility(View.GONE); if ("1".equals(bean.getIslive())) { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //直播中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType())); mType.setVisibility(View.VISIBLE); @@ -213,7 +213,7 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { live_type.setVisibility(View.VISIBLE); mLiveState.setText(mContext.getString(R.string.lives_state)); } else { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //休息中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING)); mType.setVisibility(View.GONE); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java index 518ad4f96..4702eb9aa 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java @@ -77,13 +77,13 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { viewBg.setVisibility(View.GONE); if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && height <= 1920) { - /* Picasso.with(mContext) + Picasso.with(mContext) .load(bean.getContent_pic_size_two()) - .into(liveType);*/ + .into(liveType); } else if (bean.getContent_pic_size_three() != null && !bean.getContent_pic_size_three().equals("") && height > 1920) { - /* Picasso.with(mContext) + Picasso.with(mContext) .load(bean.getContent_pic_size_three()) - .into(liveType);*/ + .into(liveType); } ImgLoader.display(itemView.getContext(), bean.getThumb(), mCover, 400, 400); bgs.setVisibility(View.VISIBLE); @@ -112,7 +112,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { mNum.setText(formatBigNum.formatBigNum(bean.getHot_num())); views.setVisibility(View.GONE); if ("1".equals(bean.getIslive())) { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //直播中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType())); mType.setVisibility(View.VISIBLE); @@ -121,7 +121,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { liveType.setVisibility(View.VISIBLE); mLiveState.setText(mContext.getString(R.string.lives_state)); } else { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //休息中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING)); mType.setVisibility(View.GONE); @@ -157,20 +157,20 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { viewBg.setVisibility(View.GONE); } RelativeLayout.LayoutParams dragon_moneyLayoutParams = (RelativeLayout.LayoutParams) dragon_money.getLayoutParams(); - /* if (bean.getRedPacketStatus() == 1) { + if (bean.getRedPacketStatus() == 1) { dragon_moneyLayoutParams.topMargin = DpUtil.dp2px(55); redPacket.setVisibility(View.VISIBLE); } else { dragon_moneyLayoutParams.topMargin = DpUtil.dp2px(25); redPacket.setVisibility(View.GONE); - }*/ - /* if (bean.getSendMoneyLongStatus() == 1) { + } + if (bean.getSendMoneyLongStatus() == 1) { dragon_money.setLayoutParams(dragon_moneyLayoutParams); dragon_money.setVisibility(View.VISIBLE); } else { dragon_money.setVisibility(View.GONE); - }*/ + } RxView.clicks(itemView) .throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件 .subscribe(new Observer() { diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index 70f8fed77..2769bb655 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -163,9 +163,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { - /* if (position == 4) { + if (position == 4) { return 2; - }*/ + } return 1; } }); @@ -190,7 +190,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { pp = 1; MainHttpUtil.getHot(p, callback); - /*LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() { + LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { if (mWeekListBean != null) { @@ -211,10 +211,10 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement Constants.getWeekIntIndex = Constants.getWeekIntIndex + 1; MainHttpUtil.getHot(p, callback); } - });*/ + }); } else { pp = 0; - if (select == 0) { + if(select==0){ select = list.get(0).getId(); } MainHttpUtil.getClassLive(select, p, callback); diff --git a/main/src/main/java/com/yunbao/main/views/SearchRecommendBodyItemViewHolder.java b/main/src/main/java/com/yunbao/main/views/SearchRecommendBodyItemViewHolder.java index 6c300730c..1e66d228c 100644 --- a/main/src/main/java/com/yunbao/main/views/SearchRecommendBodyItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/SearchRecommendBodyItemViewHolder.java @@ -59,7 +59,7 @@ public class SearchRecommendBodyItemViewHolder extends RecyclerView.ViewHolder { public void showData(AnchorRecommendItemModel model, int height) { Context mContext = itemView.getContext(); liveType.setImageDrawable(null); - /*if (model.getContentPicSizeTwo() != null && !model.getContentPicSizeTwo().equals("") && height <= 1920) { + if (model.getContentPicSizeTwo() != null && !model.getContentPicSizeTwo().equals("") && height <= 1920) { Picasso.with(mContext) .load(model.getContentPicSizeTwo()) .into(liveType); @@ -67,7 +67,7 @@ public class SearchRecommendBodyItemViewHolder extends RecyclerView.ViewHolder { Picasso.with(mContext) .load(model.getContentPicSizeThree()) .into(liveType); - }*/ + } ImgLoader.display(itemView.getContext(), model.getThumb(), mCover); bgs.setVisibility(View.VISIBLE); pkico.setVisibility(View.GONE); @@ -95,22 +95,22 @@ public class SearchRecommendBodyItemViewHolder extends RecyclerView.ViewHolder { mNum.setText(formatBigNum.formatBigNum(String.valueOf(model.getHotNum()))); views.setVisibility(View.GONE); if (TextUtils.equals("1", model.getIslive())) { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //直播中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(Integer.parseInt(model.getType()))); mType.setVisibility(View.VISIBLE); mLiveIco.setImageResource(R.mipmap.icon_main_rest_work); mNum.setVisibility(View.VISIBLE); - //liveType.setVisibility(View.VISIBLE); + liveType.setVisibility(View.VISIBLE); mLiveState.setText(mContext.getString(R.string.lives_state)); } else { - //views.setVisibility(View.VISIBLE); + views.setVisibility(View.VISIBLE); //休息中 mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING)); mType.setVisibility(View.GONE); mLiveIco.setImageResource(R.mipmap.icon_main_rest_spot); mLiveState.setText(mContext.getString(R.string.rest_state)); - //liveType.setVisibility(View.GONE); + liveType.setVisibility(View.GONE); mNum.setVisibility(View.GONE); }//防抖 RxView.clicks(mCover)