From 3bf6518e2542be62103bdcde085512f41ac8c319 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 6 Apr 2023 14:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=83=E6=84=BF=E5=8D=95=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/WishModel2.java | 160 ++++++++++++++++++ .../fragment/LiveNewWishListFragment.java | 20 +-- .../common/views/LiveNewWishListPopup.java | 15 +- .../yunbao/live/views/LiveRoomViewHolder.java | 45 +++-- .../live/views/PortraitLiveManager.java | 26 ++- 5 files changed, 223 insertions(+), 43 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/WishModel2.java diff --git a/common/src/main/java/com/yunbao/common/bean/WishModel2.java b/common/src/main/java/com/yunbao/common/bean/WishModel2.java new file mode 100644 index 000000000..49d54d005 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/WishModel2.java @@ -0,0 +1,160 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class WishModel2 extends BaseModel { + + @SerializedName("id") + private String id; + @SerializedName("dtime") + private String dtime; + @SerializedName("luid") + private String luid; + @SerializedName("lid") + private String lid; + @SerializedName("wishlist_icon") + private String wishlistIcon; + @SerializedName("wishlist_num") + private String wishlistNum; + @SerializedName("wishlist_progress") + private String wishlistProgress; + @SerializedName("wishlist_name") + private String wishlistName; + @SerializedName("create_time") + private String createTime; + @SerializedName("type") + private int type; + @SerializedName("gift_type") + private int giftType; + @SerializedName("price") + private int price; + + public String getId() { + return id; + } + + public WishModel2 setId(String id) { + this.id = id; + return this; + } + + public String getDtime() { + return dtime; + } + + public WishModel2 setDtime(String dtime) { + this.dtime = dtime; + return this; + } + + public String getLuid() { + return luid; + } + + public WishModel2 setLuid(String luid) { + this.luid = luid; + return this; + } + + public String getLid() { + return lid; + } + + public WishModel2 setLid(String lid) { + this.lid = lid; + return this; + } + + public String getWishlistIcon() { + return wishlistIcon; + } + + public WishModel2 setWishlistIcon(String wishlistIcon) { + this.wishlistIcon = wishlistIcon; + return this; + } + + public String getWishlistNum() { + return wishlistNum; + } + + public WishModel2 setWishlistNum(String wishlistNum) { + this.wishlistNum = wishlistNum; + return this; + } + + public String getWishlistProgress() { + return wishlistProgress; + } + + public WishModel2 setWishlistProgress(String wishlistProgress) { + this.wishlistProgress = wishlistProgress; + return this; + } + + public String getWishlistName() { + return wishlistName; + } + + public WishModel2 setWishlistName(String wishlistName) { + this.wishlistName = wishlistName; + return this; + } + + public String getCreateTime() { + return createTime; + } + + public WishModel2 setCreateTime(String createTime) { + this.createTime = createTime; + return this; + } + + public int getType() { + return type; + } + + public WishModel2 setType(int type) { + this.type = type; + return this; + } + + public int getGiftType() { + return giftType; + } + + public WishModel2 setGiftType(int giftType) { + this.giftType = giftType; + return this; + } + + public int getPrice() { + return price; + } + + public WishModel2 setPrice(int price) { + this.price = price; + return this; + } + + public int wishProgress() { + int progress = 0; + try { + progress = Integer.parseInt(wishlistNum); + } catch (NumberFormatException e) { + progress = 0; + } + return progress; + } + + public int wishCurrent() { + int current = 0; + try { + current = Integer.parseInt(wishlistProgress); + } catch (NumberFormatException e) { + current = 0; + } + return current; + } +} diff --git a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java index d87e38c21..b42186922 100644 --- a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java @@ -10,12 +10,12 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.lxj.xpopup.XPopup; import com.yunbao.common.R; import com.yunbao.common.adapter.LiveNewWishAdapter; import com.yunbao.common.bean.WishListModel; import com.yunbao.common.bean.WishModel; +import com.yunbao.common.bean.WishModel2; import com.yunbao.common.event.LiveNewWishListCloseEvent; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; @@ -24,7 +24,6 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.LiveNewWishGiftPopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; @@ -102,17 +101,16 @@ public class LiveNewWishListFragment extends BaseFragment { public void saveWish() { List wishList = liveNewWishAdapter.getWishList(); wishList.remove(wishList.size() - 1); - // 1. Gson构造器 - GsonBuilder builder = new GsonBuilder(); - // 2. 排除使用特定修饰符的字段 - builder.excludeFieldsWithoutExposeAnnotation(); - // 3. 格式良好的输出 - builder.setPrettyPrinting(); - // 4. 创建Gson对象 - Gson gson = builder.create(); + List wishList2 = new ArrayList<>(); + Gson gson = new Gson(); + for (WishModel model : wishList) { + WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class); + wishList2.add(model2); + } + LiveNetManager.get(getContext()). - setWishlistV2(type, gson.toJson(wishList), new HttpCallback() { + setWishlistV2(type, gson.toJson(wishList2), new HttpCallback() { @Override public void onSuccess(String data) { ToastUtil.show(data); diff --git a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java index c0249092b..cb2c31d04 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java @@ -20,6 +20,7 @@ import com.lxj.xpopup.core.BottomPopupView; import com.yunbao.common.R; import com.yunbao.common.adapter.LiveNewWishListAdapter; import com.yunbao.common.bean.WishModel; +import com.yunbao.common.bean.WishModel2; import com.yunbao.common.event.LiveNewWishListCloseEvent; import com.yunbao.common.event.LiveNewWishListEvent; import com.yunbao.common.fragment.LiveNewWishListFragment; @@ -287,17 +288,11 @@ public class LiveNewWishListPopup extends BottomPopupView { seasonalWish = false; break; } - List wishList = new ArrayList<>(); - // 1. Gson构造器 - GsonBuilder builder = new GsonBuilder(); - // 2. 排除使用特定修饰符的字段 - builder.excludeFieldsWithoutExposeAnnotation(); - // 3. 格式良好的输出 - builder.setPrettyPrinting(); - // 4. 创建Gson对象 - Gson gson = builder.create(); + List wishList2 = new ArrayList<>(); + Gson gson = new Gson(); + LiveNetManager.get(getContext()). - setWishlistV2(type, gson.toJson(wishList), new HttpCallback() { + setWishlistV2(type, gson.toJson(wishList2), new HttpCallback() { @Override public void onSuccess(String data) { ToastUtil.show(data); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index dfd1ef0a6..9d5628df0 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1321,6 +1321,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis updataCleanMic(); // initStarChallengeStatus(); enterRoomLeave.setVisibility(View.GONE); + topBanner1.setVisibility(View.GONE); } public void clearChat() { @@ -4046,6 +4047,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis new Handler(Looper.getMainLooper()).postDelayed(this::initPkRank, 300); break; case PK_TWO_END: + EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", "")); closePkTwo(); showAnchorSayAndCallAnchor(); @@ -4493,23 +4495,33 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } - public void updateTopBanner(WishModel wishListProgress) { - if (mTopBannerList == null) { - mTopBannerList = new ArrayList<>(); - } - topBanner1.setVisibility(View.VISIBLE); - BannerBean bannerBean = new BannerBean(); - bannerBean.setWishlistIcon(wishListProgress.getWishlistIcon()) - .setWishlistName(wishListProgress.getWishlistName()) - .setWishlistNum(wishListProgress.getWishlistNum()) - .setWishlistProgress(wishListProgress.getWishlistProgress()) - .setmLink(CommonAppConfig.HOST + "/index.php") - .setType(1) + private WishModel wishListProgress; + + public LiveRoomViewHolder setWishListProgress(WishModel wishListProgress) { + this.wishListProgress = wishListProgress; + return this; + } + + public void updateTopBanner() { + if (!TextUtils.isEmpty(wishListProgress.getWishlistName())||!TextUtils.isEmpty(wishListProgress.getWishlistProgress())) { + if (mTopBannerList == null) { + mTopBannerList = new ArrayList<>(); + } + topBanner1.setVisibility(View.VISIBLE); + BannerBean bannerBean = new BannerBean(); + bannerBean.setWishlistIcon(wishListProgress.getWishlistIcon()) + .setWishlistName(wishListProgress.getWishlistName()) + .setWishlistNum(wishListProgress.getWishlistNum()) + .setWishlistProgress(wishListProgress.getWishlistProgress()) + .setmLink(CommonAppConfig.HOST + "/index.php") + .setType(1) + + ; + bannerBean.setShow_type("2"); + mTopBannerList.add(bannerBean); + topBanner1.update(mTopBannerList); + } - ; - bannerBean.setShow_type("2"); - mTopBannerList.add(bannerBean); - topBanner1.update(mTopBannerList); } public void initTopBanner() { @@ -4590,6 +4602,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis System.out.println("!>>>>> 获取联系方式:" + error); } }); + updateTopBanner(); } private void checkNewLetter() { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index c89f0513e..1b8021dcd 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -40,6 +40,7 @@ import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserBean; +import com.yunbao.common.bean.WishModel; import com.yunbao.common.custom.MyViewPager; import com.yunbao.common.event.FollowEvent; import com.yunbao.common.event.LiveFloatEvent; @@ -188,7 +189,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private int landscape; private String leaveStream = "", leaveGroupId = ""; public static PortraitLiveManager portraitLiveManager; - + private WishModel wishListProgress; public PortraitLiveManager setQuitF(boolean quitF) { isQuitF = quitF; @@ -251,8 +252,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public void run() { loading.setVisibility(View.GONE); enterRoomLeaveHandler.post(enterRoomLeaveRunnable); + topBannerHandler.postDelayed(topBannerRunnable, 6000); } }; + private Runnable topBannerRunnable = new Runnable() { + @Override + public void run() { + if (mLiveRoomViewHolder != null) { + //初始化顶部banner + mLiveRoomViewHolder.initTopBanner(); + + } + + } + }; + private Handler topBannerHandler = new Handler(); @Override public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { @@ -339,6 +353,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.resetView(); enterRoomModel.clear(); enterRoomLeaveHandler.removeCallbacks(enterRoomLeaveRunnable); + topBannerHandler.removeCallbacks(topBannerRunnable); mLiveRoomViewHolder.setAvatar(data.getAvatar()); mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); mLiveRoomViewHolder.setName(data.getUserNiceName()); @@ -477,12 +492,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.setMedaRankNum(data.getEnterRoomInfo().getMedalRankNum()); //初始化女神说 mLiveRoomViewHolder.initAnchorSay(); - //初始化顶部banner - mLiveRoomViewHolder.initTopBanner(); + + wishListProgress = data.getWishListProgress(); //心愿单顶部bannner - if (data.getWishListProgress().getIsShow()!=0){ - mLiveRoomViewHolder.updateTopBanner(data.getWishListProgress()); - } + + mLiveRoomViewHolder.setWishListProgress(wishListProgress); isattention = Integer.parseInt(data.getEnterRoomInfo().getIsattention()); if (isattention == 0) {