update 红包专区

This commit is contained in:
zlzw 2023-06-27 13:54:18 +08:00
parent 3bf594d0b5
commit 501a7b482b
9 changed files with 464 additions and 235 deletions

View File

@ -5,6 +5,7 @@ import android.os.Parcelable;
import android.text.TextUtils; import android.text.TextUtils;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -51,6 +52,8 @@ public class LiveBean implements Parcelable {
private String recommendCardtype = ""; private String recommendCardtype = "";
private String recommendCardIconSizeTwo = ""; private String recommendCardIconSizeTwo = "";
private String recommendCardIconSizeThree = ""; private String recommendCardIconSizeThree = "";
@SerializedName("red_packet_status")
private int redPacketStatus;
private Map<String,String> params;//用于跳转Activity时扩展参数从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框 private Map<String,String> params;//用于跳转Activity时扩展参数从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框
@ -382,6 +385,14 @@ public class LiveBean implements Parcelable {
this.islive = islive; 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 + '\'' + ", recommendCardtype='" + recommendCardtype + '\'' +
", recommendCardIconSizeTwo='" + recommendCardIconSizeTwo + '\'' + ", recommendCardIconSizeTwo='" + recommendCardIconSizeTwo + '\'' +
", recommendCardIconSizeThree='" + recommendCardIconSizeThree + '\'' + ", recommendCardIconSizeThree='" + recommendCardIconSizeThree + '\'' +
", redPacketStatus=" + redPacketStatus +
", params=" + params + ", params=" + params +
", mWeekList=" + mWeekList + ", mWeekList=" + mWeekList +
'}'; '}';

View File

@ -68,7 +68,7 @@ public class LiveTaskModel extends BaseModel {
'}'; '}';
} }
public static class NewUser { public static class NewUser implements Serializable{
@SerializedName("isNew") @SerializedName("isNew")
private int isNew; private int isNew;
@SerializedName("endTime") @SerializedName("endTime")

View File

@ -79,9 +79,11 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
ImageView dr_pk_ico; ImageView dr_pk_ico;
View views; View views;
ImageView bgs; ImageView bgs;
private View redPacket;
public Vh(View itemView) { public Vh(View itemView) {
super(itemView); super(itemView);
redPacket = itemView.findViewById(R.id.red_packet);
live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view); live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view);
mCover = (ImageView) itemView.findViewById(R.id.cover); mCover = (ImageView) itemView.findViewById(R.id.cover);
mName = (TextView) itemView.findViewById(R.id.name); mName = (TextView) itemView.findViewById(R.id.name);
@ -220,6 +222,11 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
if (bean.getIs_week() != null && bean.getIs_week().equals("1")) { if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
views.setVisibility(View.GONE); views.setVisibility(View.GONE);
} }
if (bean.getRedPacketStatus() == 1) {
redPacket.setVisibility(View.VISIBLE);
} else {
redPacket.setVisibility(View.GONE);
}
} }
} }

View File

@ -159,6 +159,13 @@ public class MainHttpUtil {
.execute(callback); .execute(callback);
} }
/**
* 首页红包专区
*/
public static void getRedPacket(int p, HttpCallback callback) {
HttpClient.getInstance().get("Home.getRedPacket", MainHttpConsts.GET_RANDOM)
.execute(callback);
}
/** /**
* 首页 * 首页

View File

@ -32,6 +32,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder {
private ImageView mCover, liveType, mLiveIco, mType, pkico, drPkIco, pkAvatar, viewBg; private ImageView mCover, liveType, mLiveIco, mType, pkico, drPkIco, pkAvatar, viewBg;
private ImageView bgs; private ImageView bgs;
private View views; private View views;
private View redPacket;
private TextView mLiveState, mTitle, mName, mNum; private TextView mLiveState, mTitle, mName, mNum;
public MainHomeLiveItemViewHolder(@NonNull View itemView) { 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.live_info_view).setVisibility(View.VISIBLE);
itemView.findViewById(R.id.lt_week_list).setVisibility(View.GONE); itemView.findViewById(R.id.lt_week_list).setVisibility(View.GONE);
mCover = itemView.findViewById(R.id.cover); mCover = itemView.findViewById(R.id.cover);
redPacket = itemView.findViewById(R.id.red_packet);
bgs = itemView.findViewById(R.id.bgs); bgs = itemView.findViewById(R.id.bgs);
liveType = itemView.findViewById(R.id.live_type); liveType = itemView.findViewById(R.id.live_type);
views = itemView.findViewById(R.id.views); views = itemView.findViewById(R.id.views);
@ -147,6 +149,11 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder {
} else { } else {
viewBg.setVisibility(View.GONE); viewBg.setVisibility(View.GONE);
} }
if (bean.getRedPacketStatus() == 1) {
redPacket.setVisibility(View.VISIBLE);
} else {
redPacket.setVisibility(View.GONE);
}
RxView.clicks(itemView) RxView.clicks(itemView)
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件 .throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
.subscribe(new Observer<Unit>() { .subscribe(new Observer<Unit>() {

View File

@ -46,6 +46,7 @@ public class MainHomeLiveWeekItemViewHolder<T> extends RecyclerView.ViewHolder {
private List<WeekListBean> weekList = new ArrayList<>(); private List<WeekListBean> weekList = new ArrayList<>();
//轮询周星榜的下标 //轮询周星榜的下标
private int index = 0; private int index = 0;
private View redPacket;
public MainHomeLiveWeekItemViewHolder(@NonNull View itemView) { public MainHomeLiveWeekItemViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
@ -53,6 +54,7 @@ public class MainHomeLiveWeekItemViewHolder<T> extends RecyclerView.ViewHolder {
itemView.findViewById(R.id.live_info_view).setVisibility(View.GONE); itemView.findViewById(R.id.live_info_view).setVisibility(View.GONE);
itemView.findViewById(R.id.lt_week_list).setVisibility(View.VISIBLE); itemView.findViewById(R.id.lt_week_list).setVisibility(View.VISIBLE);
imgWeekHead = itemView.findViewById(R.id.img_week_head); imgWeekHead = itemView.findViewById(R.id.img_week_head);
redPacket=itemView.findViewById(R.id.red_packet);
weekSvga = (SVGAImageView) itemView.findViewById(R.id.week_svga); weekSvga = (SVGAImageView) itemView.findViewById(R.id.week_svga);
viewflipperBanner = itemView.findViewById(R.id.viewflipper_banner); viewflipperBanner = itemView.findViewById(R.id.viewflipper_banner);
imgWeekHead.setVisibility(View.GONE); imgWeekHead.setVisibility(View.GONE);
@ -119,6 +121,11 @@ public class MainHomeLiveWeekItemViewHolder<T> extends RecyclerView.ViewHolder {
} }
bannerHandler.removeCallbacks(mFlipRunnable); bannerHandler.removeCallbacks(mFlipRunnable);
bannerHandler.postDelayed(mFlipRunnable, delayMillis); bannerHandler.postDelayed(mFlipRunnable, delayMillis);
if (bean.getRedPacketStatus() == 1) {
redPacket.setVisibility(View.VISIBLE);
} else {
redPacket.setVisibility(View.GONE);
}
RxView.clicks(itemView) RxView.clicks(itemView)
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件 .throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
.subscribe(new Observer<Unit>() { .subscribe(new Observer<Unit>() {

View File

@ -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<LiveBean> {
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<LiveBean>() {
@Override
public RefreshAdapter<LiveBean> 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<LiveBean> processData(String[] info) {
if(pp == 1){
return JSON.parseArray(Arrays.toString(info), LiveBean.class);
}else{
return null;
}
}
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
EventBus.getDefault().post(new AnchorRecommendModel());
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<LiveBean> 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();
}
}

View File

@ -8,7 +8,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.activity.RedPacketListActivity; import com.yunbao.main.activity.RedPacketListActivity;
@ -21,6 +20,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
private MainHomeFollLiveViewHolder mainHomeFollLiveViewHolder; private MainHomeFollLiveViewHolder mainHomeFollLiveViewHolder;
private MainHomeLiveViewHolder mainHomeLiveViewHolder; private MainHomeLiveViewHolder mainHomeLiveViewHolder;
private MainHomeRecomLiveViewHolder mainHomeRecomLiveViewHolder; private MainHomeRecomLiveViewHolder mainHomeRecomLiveViewHolder;
private MainHomeRedPacketLiveViewHolder mainHomeRedPacketLiveViewHolder;
private ImageView img_trophy; private ImageView img_trophy;
@ -73,6 +73,9 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
} else if (position == 2) { } else if (position == 2) {
mainHomeRecomLiveViewHolder = new MainHomeRecomLiveViewHolder(mContext, parent); mainHomeRecomLiveViewHolder = new MainHomeRecomLiveViewHolder(mContext, parent);
vh = mainHomeRecomLiveViewHolder; vh = mainHomeRecomLiveViewHolder;
}else if(position==3){
mainHomeRedPacketLiveViewHolder=new MainHomeRedPacketLiveViewHolder(mContext,parent);
vh=mainHomeRedPacketLiveViewHolder;
} }
if (vh == null) { if (vh == null) {
@ -90,7 +93,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
@Override @Override
protected int getPageCount() { protected int getPageCount() {
return 3; return 4;
} }
@Override @Override
@ -99,6 +102,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
mContext.getString(R.string.follow), mContext.getString(R.string.follow),
mContext.getString(R.string.hot), mContext.getString(R.string.hot),
mContext.getString(R.string.recomment), mContext.getString(R.string.recomment),
"红包专区",
}; };
} }

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
@ -204,11 +205,11 @@
android:id="@+id/viewflipper_banner" android:id="@+id/viewflipper_banner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:flipInterval="1000"
android:visibility="gone"
android:layout_margin="3dp" android:layout_margin="3dp"
android:flipInterval="1000"
android:inAnimation="@anim/vice_screen_come_in" android:inAnimation="@anim/vice_screen_come_in"
android:outAnimation="@anim/vice_screen_come_out" /> android:outAnimation="@anim/vice_screen_come_out"
android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/img_week_head" android:id="@+id/img_week_head"
@ -281,7 +282,21 @@
android:background="@drawable/border_f1f1f1" android:background="@drawable/border_f1f1f1"
android:visibility="gone" android:visibility="gone"
app:mvDirection="bottom_to_top" app:mvDirection="bottom_to_top"
app:mvInterval="3000" /> app:mvInterval="3000">
</com.xj.marqueeview.MarqueeView>
<ImageView
android:id="@+id/red_packet"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="25dp"
android:visibility="gone"
app:srcCompat="@mipmap/icon_red_packet"
tools:visibility="visible" />
</RelativeLayout> </RelativeLayout>