From 501a7b482b38ea66ccab90aac0212415ea48e7e6 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 27 Jun 2023 13:54:18 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=BA=A2=E5=8C=85=E4=B8=93=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/common/bean/LiveBean.java | 12 + .../com/yunbao/common/bean/LiveTaskModel.java | 2 +- .../adapter/MainHomeRemFollLiveAdapter.java | 7 + .../com/yunbao/main/http/MainHttpUtil.java | 7 + .../views/MainHomeLiveItemViewHolder.java | 7 + .../views/MainHomeLiveWeekItemViewHolder.java | 7 + .../MainHomeRedPacketLiveViewHolder.java | 170 +++++++ .../yunbao/main/views/MainHomeViewHolder.java | 8 +- .../main/res/layout/item_main_home_lives.xml | 479 +++++++++--------- 9 files changed, 464 insertions(+), 235 deletions(-) create mode 100644 main/src/main/java/com/yunbao/main/views/MainHomeRedPacketLiveViewHolder.java diff --git a/common/src/main/java/com/yunbao/common/bean/LiveBean.java b/common/src/main/java/com/yunbao/common/bean/LiveBean.java index 7dbafa055..f4cec2ec4 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveBean.java @@ -5,6 +5,7 @@ import android.os.Parcelable; import android.text.TextUtils; import com.alibaba.fastjson.annotation.JSONField; +import com.google.gson.annotations.SerializedName; import java.util.ArrayList; import java.util.List; @@ -51,6 +52,8 @@ public class LiveBean implements Parcelable { private String recommendCardtype = ""; private String recommendCardIconSizeTwo = ""; private String recommendCardIconSizeThree = ""; + @SerializedName("red_packet_status") + private int redPacketStatus; private Map params;//用于跳转Activity时扩展参数,例:从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框 @@ -382,6 +385,14 @@ public class LiveBean implements Parcelable { this.islive = islive; } + public int getRedPacketStatus() { + return redPacketStatus; + } + + public void setRedPacketStatus(int redPacketStatus) { + this.redPacketStatus = redPacketStatus; + } + /** * 显示靓号 */ @@ -529,6 +540,7 @@ public class LiveBean implements Parcelable { ", recommendCardtype='" + recommendCardtype + '\'' + ", recommendCardIconSizeTwo='" + recommendCardIconSizeTwo + '\'' + ", recommendCardIconSizeThree='" + recommendCardIconSizeThree + '\'' + + ", redPacketStatus=" + redPacketStatus + ", params=" + params + ", mWeekList=" + mWeekList + '}'; diff --git a/common/src/main/java/com/yunbao/common/bean/LiveTaskModel.java b/common/src/main/java/com/yunbao/common/bean/LiveTaskModel.java index 647c776a9..c33012e1f 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveTaskModel.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveTaskModel.java @@ -68,7 +68,7 @@ public class LiveTaskModel extends BaseModel { '}'; } - public static class NewUser { + public static class NewUser implements Serializable{ @SerializedName("isNew") private int isNew; @SerializedName("endTime") 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 461ec6c9f..5a6110abf 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollLiveAdapter.java @@ -79,9 +79,11 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { ImageView dr_pk_ico; View views; ImageView bgs; + private View redPacket; public Vh(View itemView) { super(itemView); + redPacket = itemView.findViewById(R.id.red_packet); live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view); mCover = (ImageView) itemView.findViewById(R.id.cover); mName = (TextView) itemView.findViewById(R.id.name); @@ -220,6 +222,11 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter { if (bean.getIs_week() != null && bean.getIs_week().equals("1")) { views.setVisibility(View.GONE); } + if (bean.getRedPacketStatus() == 1) { + redPacket.setVisibility(View.VISIBLE); + } else { + redPacket.setVisibility(View.GONE); + } } } diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java index 5283180ca..0dd121ac5 100644 --- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java +++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java @@ -159,6 +159,13 @@ public class MainHttpUtil { .execute(callback); } + /** + * 首页红包专区 + */ + public static void getRedPacket(int p, HttpCallback callback) { + HttpClient.getInstance().get("Home.getRedPacket", MainHttpConsts.GET_RANDOM) + .execute(callback); + } /** * 首页 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 740648c33..d852d4bec 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java @@ -32,6 +32,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { private ImageView mCover, liveType, mLiveIco, mType, pkico, drPkIco, pkAvatar, viewBg; private ImageView bgs; private View views; + private View redPacket; private TextView mLiveState, mTitle, mName, mNum; public MainHomeLiveItemViewHolder(@NonNull View itemView) { @@ -40,6 +41,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { itemView.findViewById(R.id.live_info_view).setVisibility(View.VISIBLE); itemView.findViewById(R.id.lt_week_list).setVisibility(View.GONE); mCover = itemView.findViewById(R.id.cover); + redPacket = itemView.findViewById(R.id.red_packet); bgs = itemView.findViewById(R.id.bgs); liveType = itemView.findViewById(R.id.live_type); views = itemView.findViewById(R.id.views); @@ -147,6 +149,11 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder { } else { viewBg.setVisibility(View.GONE); } + if (bean.getRedPacketStatus() == 1) { + redPacket.setVisibility(View.VISIBLE); + } else { + redPacket.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/MainHomeLiveWeekItemViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java index 7c00a8cb9..237223194 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java @@ -46,6 +46,7 @@ public class MainHomeLiveWeekItemViewHolder extends RecyclerView.ViewHolder { private List weekList = new ArrayList<>(); //轮询周星榜的下标 private int index = 0; + private View redPacket; public MainHomeLiveWeekItemViewHolder(@NonNull View itemView) { super(itemView); @@ -53,6 +54,7 @@ public class MainHomeLiveWeekItemViewHolder extends RecyclerView.ViewHolder { itemView.findViewById(R.id.live_info_view).setVisibility(View.GONE); itemView.findViewById(R.id.lt_week_list).setVisibility(View.VISIBLE); imgWeekHead = itemView.findViewById(R.id.img_week_head); + redPacket=itemView.findViewById(R.id.red_packet); weekSvga = (SVGAImageView) itemView.findViewById(R.id.week_svga); viewflipperBanner = itemView.findViewById(R.id.viewflipper_banner); imgWeekHead.setVisibility(View.GONE); @@ -119,6 +121,11 @@ public class MainHomeLiveWeekItemViewHolder extends RecyclerView.ViewHolder { } bannerHandler.removeCallbacks(mFlipRunnable); bannerHandler.postDelayed(mFlipRunnable, delayMillis); + if (bean.getRedPacketStatus() == 1) { + redPacket.setVisibility(View.VISIBLE); + } else { + redPacket.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/MainHomeRedPacketLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeRedPacketLiveViewHolder.java new file mode 100644 index 000000000..b6d66fda7 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeRedPacketLiveViewHolder.java @@ -0,0 +1,170 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.recyclerview.widget.GridLayoutManager; + +import com.alibaba.fastjson.JSON; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.main.R; +import com.yunbao.main.activity.MainActivity; +import com.yunbao.main.activity.WeekWebViewActivity; +import com.yunbao.main.adapter.MainHomeRemFollLiveAdapter; +import com.yunbao.main.http.MainHttpConsts; +import com.yunbao.main.http.MainHttpUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.Arrays; +import java.util.List; + +/** + * 首页红包专区 + */ +public class MainHomeRedPacketLiveViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { + private CommonRefreshView mRefreshView; + private MainHomeRemFollLiveAdapter mAdapter; + + public MainHomeRedPacketLiveViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_live_recom; + } + + public static int pp; + + //显示顶部商城tab时,显示底部tabGroup + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUpdata(String str) { + if ("Updata".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + mRefreshView.mRecyclerView.scrollToPosition(0); + } + }else if ("blacklist".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + } + } + } + + @Override + public void init() { + + mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView); + mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); + EventBus.getDefault().register(this); + GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false); + mRefreshView.setLayoutManager(gridLayoutManager); + ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0); + decoration.setOnlySetItemOffsetsButNoDraw(true); + mRefreshView.setItemDecoration(decoration); + mRefreshView.setRecyclerViewAdapter(mAdapter); + mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + if (mAdapter == null) { + mAdapter = new MainHomeRemFollLiveAdapter(mContext, MainActivity.Height); + mAdapter.setOnItemClickListener(MainHomeRedPacketLiveViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + pp = p; + MainHttpUtil.getRedPacket(p, callback); + } + + @Override + public List processData(String[] info) { + if(pp == 1){ + return JSON.parseArray(Arrays.toString(info), LiveBean.class); + }else{ + return null; + } + } + + @Override + public void onRefreshSuccess(List list, int count) { + EventBus.getDefault().post(new AnchorRecommendModel()); + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + + } + + @Override + public void onLoadMoreFailure() { + + } + }); + + mRefreshView.initData(); + + + } + + + + + + @Override + public void onItemClick(LiveBean bean, int position) { + if ("1".equals(bean.getIslive())) { + watchLive(bean, Constants.LIVE_HOME, position); + }else if(bean.getIs_week()!=null&&bean.getIs_week().equals("1")){ + String url = CommonAppConfig.HOST + bean.getUrl()+"?a=1"; + WeekWebViewActivity.forward(mContext, url, true); + } else { + RouteUtil.forwardUserHome(mContext, bean.getUid(),0); + } + } + + @Override + public void loadData() { +// if (mRefreshView != null) { +// mRefreshView.initData(); +// } + } + + @Override + public void release() { + MainHttpUtil.cancel(MainHttpConsts.GET_RANDOM); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + release(); + } + + @Override + public void onResume() { + super.onResume(); + + } +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index a5614849e..9c7c0ce9c 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -8,7 +8,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import com.yunbao.common.glide.ImgLoader; -import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; import com.yunbao.main.activity.RedPacketListActivity; @@ -21,6 +20,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { private MainHomeFollLiveViewHolder mainHomeFollLiveViewHolder; private MainHomeLiveViewHolder mainHomeLiveViewHolder; private MainHomeRecomLiveViewHolder mainHomeRecomLiveViewHolder; + private MainHomeRedPacketLiveViewHolder mainHomeRedPacketLiveViewHolder; private ImageView img_trophy; @@ -73,6 +73,9 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { } else if (position == 2) { mainHomeRecomLiveViewHolder = new MainHomeRecomLiveViewHolder(mContext, parent); vh = mainHomeRecomLiveViewHolder; + }else if(position==3){ + mainHomeRedPacketLiveViewHolder=new MainHomeRedPacketLiveViewHolder(mContext,parent); + vh=mainHomeRedPacketLiveViewHolder; } if (vh == null) { @@ -90,7 +93,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { @Override protected int getPageCount() { - return 3; + return 4; } @Override @@ -99,6 +102,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { mContext.getString(R.string.follow), mContext.getString(R.string.hot), mContext.getString(R.string.recomment), + "红包专区", }; } diff --git a/main/src/main/res/layout/item_main_home_lives.xml b/main/src/main/res/layout/item_main_home_lives.xml index a9649e8ac..3bb1b799c 100644 --- a/main/src/main/res/layout/item_main_home_lives.xml +++ b/main/src/main/res/layout/item_main_home_lives.xml @@ -1,6 +1,7 @@ - - - + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="visible"> - - + android:layout_marginBottom="9dp" + android:paddingLeft="5dp"> - - - - - - + + + android:id="@+id/view_bg" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scaleType="fitXY" + android:visibility="gone" /> - + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + android:gravity="center" /> - + - + + + + + + + + + + + + + + + + + + + + + + + + + android:id="@+id/pk_ico" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" + android:layout_marginRight="33dp" + android:layout_marginBottom="60dp" + android:src="@mipmap/live_pk" /> - - - - - - - - - - - - - - - - - + - + - + - - - + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> - + android:layout_marginBottom="9dp" + android:paddingLeft="5dp"> - + + + - + - - - + android:layout_alignParentBottom="true" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:orientation="vertical"> - + android:layout_marginLeft="6dp" + android:layout_marginBottom="12dp"> - + - - - + - + + + - + + + + + + +