From 70a91fedf31d70df17d37f984fff868ff0ec8491 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 30 Mar 2023 14:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=83=E6=84=BF=E5=8D=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/build.gradle | 1 + .../common/adapter/LiveNewWishAdapter.java | 91 +++++++++ .../adapter/LiveNewWishGiftAdapter.java | 56 ++++++ .../adapter/LiveNewWishListAdapter.java | 30 +++ .../com/yunbao/common/bean/GiftListModel.java | 72 +++++++ .../common/bean/WishListGiftConfModel.java | 46 +++++ .../com/yunbao/common/bean/WishListModel.java | 3 +- .../yunbao/common/bean/WishListModel2.java | 31 +++ .../com/yunbao/common/bean/WishModel.java | 52 +++++ .../common/event/LiveNewWishGiftEvent.java | 17 ++ .../common/event/LiveNewWishListEvent.java | 27 +++ .../fragment/LiveNewWishGiftFragment.java | 136 +++++++++++++ .../fragment/LiveNewWishListFragment.java | 84 ++++++++ .../com/yunbao/common/http/PDLiveApi.java | 36 ++++ .../common/http/live/LiveNetManager.java | 52 +++++ .../yunbao/common/utils/WordsTypeUtil.java | 26 +++ .../common/views/DayWishItemViewHolder.java | 106 ++++++++++ .../common/views/LiveNewWishGiftPopup.java | 182 ++++++++++++++++++ .../views/LiveNewWishGiftViewHolder.java | 37 ++++ .../common/views/LiveNewWishListPopup.java | 171 ++++++++++++++++ .../common/views/LunarWishItemViewHolder.java | 12 ++ .../views/SeasonalWishItemViewHolder.java | 12 ++ .../common/views/WeekWishItemViewHolder.java | 12 ++ .../res/drawable/background_wilsh_gitf.xml | 13 ++ .../res/drawable/background_wilsh_tab.xml | 17 ++ .../drawable/background_wilsh_tab_gift.xml | 15 ++ .../res/drawable/background_wish_item.xml | 8 + .../main/res/drawable/bg_wish_gitf_button.xml | 6 + .../src/main/res/drawable/bg_xyd.png | Bin .../src/main/res/drawable/bg_xyd_add_item.png | Bin .../src/main/res/drawable/bg_xyd_button.png | Bin .../src/main/res/drawable/bg_xyd_number.png | Bin .../main/res/drawable/progress_wishlist2.xml | 44 +++++ .../res/layout/dialog_live_new_wish_gitf.xml | 44 +++++ .../res/layout/dialog_live_new_wish_list.xml | 29 +++ common/src/main/res/layout/item_day_wish.xml | 134 +++++++++++++ common/src/main/res/layout/item_gitf_wish.xml | 24 +++ .../src/main/res/layout/item_lunar_wish.xml | 38 ++++ .../main/res/layout/item_seasonal_wish.xml | 38 ++++ common/src/main/res/layout/item_week_wish.xml | 38 ++++ .../main/res/layout/view_live_new_wish.xml | 35 ++++ .../res/layout/view_live_new_wish_gitf.xml | 29 +++ .../res/layout/view_tablaout_wish_item.xml | 9 + .../mipmap-xxhdpi/background_wish_item.png | Bin 0 -> 60878 bytes .../main/res/mipmap-xxhdpi/bg_day_wish.png | Bin 0 -> 188003 bytes .../main/res/mipmap-xxhdpi/bg_lunar_wish.png | Bin 0 -> 562153 bytes .../res/mipmap-xxhdpi/bg_seasonal_wish.png | Bin 0 -> 651378 bytes .../main/res/mipmap-xxhdpi/icon_cancel.png | Bin 0 -> 729 bytes .../src/main/res/mipmap-xxhdpi}/img_lu_bg.png | Bin common/src/main/res/values/strings.xml | 9 +- .../live/activity/LiveRyAnchorActivity.java | 17 +- .../live/views/LiveNewReadyRyViewHolder.java | 17 +- .../yunbao/live/views/LiveRoomViewHolder.java | 5 +- .../res/layout/dialog_live_gift_wishlist.xml | 3 +- .../main/res/layout/view_enter_room_leave.xml | 2 +- 55 files changed, 1848 insertions(+), 18 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java create mode 100644 common/src/main/java/com/yunbao/common/adapter/LiveNewWishGiftAdapter.java create mode 100644 common/src/main/java/com/yunbao/common/adapter/LiveNewWishListAdapter.java create mode 100644 common/src/main/java/com/yunbao/common/bean/GiftListModel.java create mode 100644 common/src/main/java/com/yunbao/common/bean/WishListGiftConfModel.java create mode 100644 common/src/main/java/com/yunbao/common/bean/WishListModel2.java create mode 100644 common/src/main/java/com/yunbao/common/event/LiveNewWishGiftEvent.java create mode 100644 common/src/main/java/com/yunbao/common/event/LiveNewWishListEvent.java create mode 100644 common/src/main/java/com/yunbao/common/fragment/LiveNewWishGiftFragment.java create mode 100644 common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java create mode 100644 common/src/main/java/com/yunbao/common/views/DayWishItemViewHolder.java create mode 100644 common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java create mode 100644 common/src/main/java/com/yunbao/common/views/LiveNewWishGiftViewHolder.java create mode 100644 common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java create mode 100644 common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java create mode 100644 common/src/main/java/com/yunbao/common/views/SeasonalWishItemViewHolder.java create mode 100644 common/src/main/java/com/yunbao/common/views/WeekWishItemViewHolder.java create mode 100644 common/src/main/res/drawable/background_wilsh_gitf.xml create mode 100644 common/src/main/res/drawable/background_wilsh_tab.xml create mode 100644 common/src/main/res/drawable/background_wilsh_tab_gift.xml create mode 100644 common/src/main/res/drawable/background_wish_item.xml create mode 100644 common/src/main/res/drawable/bg_wish_gitf_button.xml rename {live => common}/src/main/res/drawable/bg_xyd.png (100%) rename {live => common}/src/main/res/drawable/bg_xyd_add_item.png (100%) rename {live => common}/src/main/res/drawable/bg_xyd_button.png (100%) rename {live => common}/src/main/res/drawable/bg_xyd_number.png (100%) create mode 100644 common/src/main/res/drawable/progress_wishlist2.xml create mode 100644 common/src/main/res/layout/dialog_live_new_wish_gitf.xml create mode 100644 common/src/main/res/layout/dialog_live_new_wish_list.xml create mode 100644 common/src/main/res/layout/item_day_wish.xml create mode 100644 common/src/main/res/layout/item_gitf_wish.xml create mode 100644 common/src/main/res/layout/item_lunar_wish.xml create mode 100644 common/src/main/res/layout/item_seasonal_wish.xml create mode 100644 common/src/main/res/layout/item_week_wish.xml create mode 100644 common/src/main/res/layout/view_live_new_wish.xml create mode 100644 common/src/main/res/layout/view_live_new_wish_gitf.xml create mode 100644 common/src/main/res/layout/view_tablaout_wish_item.xml create mode 100644 common/src/main/res/mipmap-xxhdpi/background_wish_item.png create mode 100644 common/src/main/res/mipmap-xxhdpi/bg_day_wish.png create mode 100644 common/src/main/res/mipmap-xxhdpi/bg_lunar_wish.png create mode 100644 common/src/main/res/mipmap-xxhdpi/bg_seasonal_wish.png create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_cancel.png rename {live/src/main/res/mipmap-xxxhdpi => common/src/main/res/mipmap-xxhdpi}/img_lu_bg.png (100%) diff --git a/common/build.gradle b/common/build.gradle index bc5c7ddd9..e4fb1fd12 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -190,4 +190,5 @@ dependencies { api 'com.github.li-xiaojun:XPopup:2.9.1' + api 'com.github.shenbengit:PagerGridLayoutManager:1.1.7' } diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java new file mode 100644 index 000000000..bc987a6bf --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java @@ -0,0 +1,91 @@ +package com.yunbao.common.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.WishModel; +import com.yunbao.common.views.DayWishItemViewHolder; +import com.yunbao.common.views.LunarWishItemViewHolder; +import com.yunbao.common.views.SeasonalWishItemViewHolder; +import com.yunbao.common.views.WeekWishItemViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class LiveNewWishAdapter extends RecyclerView.Adapter { + private int type = 0; + private List wishList = new ArrayList<>(); + + public void addData(List wishModelList, int type) { + this.type = type; + wishList.clear(); + wishList.addAll(wishModelList); + wishList.add(null); + notifyDataSetChanged(); + } + + public void addGiftListModel(WishModel model) { + wishList.add(0, model); + notifyDataSetChanged(); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (type == 1) { + View dayWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_day_wish, parent, false); + return new DayWishItemViewHolder(dayWish); + } else if (type == 2) { + View weekWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_week_wish, parent, false); + return new WeekWishItemViewHolder(weekWish); + } else if (type == 3) { + View lunarWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_lunar_wish, parent, false); + return new LunarWishItemViewHolder(lunarWish); + } else { + View seasonalWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_seasonal_wish, parent, false); + return new SeasonalWishItemViewHolder(seasonalWish); + } + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (position == wishList.size()) return; + if (holder instanceof DayWishItemViewHolder) { + DayWishItemViewHolder dayWishItemViewHolder = (DayWishItemViewHolder) holder; + dayWishItemViewHolder.steDayWishData(wishList.get(position), position, new DayWishItemViewHolder.DayWishItemListener() { + @Override + public void onDelete(int index) { + wishList.remove(index); + notifyDataSetChanged(); + } + + @Override + public void onUpdate(WishModel model, int index) { + wishList.remove(index); + wishList.add(index, model); + notifyItemChanged(index); + } + }); + } else if (holder instanceof WeekWishItemViewHolder) { + WeekWishItemViewHolder weekWishItemViewHolder = (WeekWishItemViewHolder) holder; + } else if (holder instanceof LunarWishItemViewHolder) { + LunarWishItemViewHolder lunarWishItemViewHolder = (LunarWishItemViewHolder) holder; + } else if (holder instanceof SeasonalWishItemViewHolder) { + SeasonalWishItemViewHolder seasonalWishItemViewHolder = (SeasonalWishItemViewHolder) holder; + } + + } + + @Override + public int getItemCount() { + return wishList.size(); + } + + +} diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishGiftAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishGiftAdapter.java new file mode 100644 index 000000000..ae3653334 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishGiftAdapter.java @@ -0,0 +1,56 @@ +package com.yunbao.common.adapter; + +import android.annotation.SuppressLint; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.GiftListModel; +import com.yunbao.common.event.LiveNewWishGiftEvent; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.LiveNewWishGiftViewHolder; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import java.util.ArrayList; +import java.util.List; + +public class LiveNewWishGiftAdapter extends RecyclerView.Adapter { + private List giftListModels = new ArrayList<>(); + + public LiveNewWishGiftAdapter(List giftListModels) { + this.giftListModels = giftListModels; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View dayWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gitf_wish, parent, false); + return new LiveNewWishGiftViewHolder(dayWish); + } + + private int index = -1; + + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) { + LiveNewWishGiftViewHolder wishGiftViewHolder = (LiveNewWishGiftViewHolder) holder; + wishGiftViewHolder.setData(giftListModels.get(position), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + index = position; + notifyDataSetChanged(); + Bus.get().post(new LiveNewWishGiftEvent().setModel(giftListModels.get(position))); + } + }); + wishGiftViewHolder.onSelect(index == position); + } + + @Override + public int getItemCount() { + return giftListModels.size(); + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishListAdapter.java new file mode 100644 index 000000000..0ce21b5d7 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishListAdapter.java @@ -0,0 +1,30 @@ +package com.yunbao.common.adapter; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager2.adapter.FragmentStateAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class LiveNewWishListAdapter extends FragmentStateAdapter { + private List list = new ArrayList<>(); + + public LiveNewWishListAdapter(@NonNull FragmentActivity fragmentActivity, List list) { + super(fragmentActivity); + this.list = list; + } + + + @NonNull + @Override + public Fragment createFragment(int position) { + return list.get(position); + } + + @Override + public int getItemCount() { + return list.size(); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/GiftListModel.java b/common/src/main/java/com/yunbao/common/bean/GiftListModel.java new file mode 100644 index 000000000..9c448c217 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/GiftListModel.java @@ -0,0 +1,72 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class GiftListModel extends BaseModel { + @SerializedName("name") + private String name; + @SerializedName("price") + private String price; + @SerializedName("img") + private String img; + @SerializedName("id") + private String id; + @SerializedName("gift_type") + private String giftType; + + public String getName() { + return name; + } + + public GiftListModel setName(String name) { + this.name = name; + return this; + } + + public String getPrice() { + return price; + } + + public GiftListModel setPrice(String price) { + this.price = price; + return this; + } + + public String getImg() { + return img; + } + + public GiftListModel setImg(String img) { + this.img = img; + return this; + } + + public String getId() { + return id; + } + + public GiftListModel setId(String id) { + this.id = id; + return this; + } + + public String getGiftType() { + return giftType; + } + + public GiftListModel setGiftType(String giftType) { + this.giftType = giftType; + return this; + } + + @Override + public String toString() { + return "GiftListModel{" + + "name='" + name + '\'' + + ", price='" + price + '\'' + + ", img='" + img + '\'' + + ", id='" + id + '\'' + + ", giftType='" + giftType + '\'' + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/WishListGiftConfModel.java b/common/src/main/java/com/yunbao/common/bean/WishListGiftConfModel.java new file mode 100644 index 000000000..6690971b1 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/WishListGiftConfModel.java @@ -0,0 +1,46 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; + +/** + * 心愿单礼物配置 + */ +public class WishListGiftConfModel extends BaseModel { + + @SerializedName("giftList") + private List giftList = new ArrayList<>(); + @SerializedName("guardList") + private List guardList = new ArrayList<>(); + @SerializedName("nobleList") + private List nobleList = new ArrayList<>(); + + public List getGiftList() { + return giftList; + } + + public WishListGiftConfModel setGiftList(List giftList) { + this.giftList = giftList; + return this; + } + + public List getGuardList() { + return guardList; + } + + public WishListGiftConfModel setGuardList(List guardList) { + this.guardList = guardList; + return this; + } + + public List getNobleList() { + return nobleList; + } + + public WishListGiftConfModel setNobleList(List nobleList) { + this.nobleList = nobleList; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/WishListModel.java b/common/src/main/java/com/yunbao/common/bean/WishListModel.java index fef8be6b9..ed4409105 100644 --- a/common/src/main/java/com/yunbao/common/bean/WishListModel.java +++ b/common/src/main/java/com/yunbao/common/bean/WishListModel.java @@ -2,11 +2,12 @@ package com.yunbao.common.bean; import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; import java.util.List; public class WishListModel extends BaseModel { @SerializedName("wishList") - private List wishList; + private List wishList = new ArrayList<>(); @SerializedName("img") private String img; diff --git a/common/src/main/java/com/yunbao/common/bean/WishListModel2.java b/common/src/main/java/com/yunbao/common/bean/WishListModel2.java new file mode 100644 index 000000000..7253057a0 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/WishListModel2.java @@ -0,0 +1,31 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class WishListModel2 extends BaseModel { + + @SerializedName("wishlist") + private List> wishlist; + @SerializedName("img") + private String img; + + public List> getWishlist() { + return wishlist; + } + + public WishListModel2 setWishlist(List> wishlist) { + this.wishlist = wishlist; + return this; + } + + public String getImg() { + return img; + } + + public WishListModel2 setImg(String img) { + this.img = img; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/WishModel.java b/common/src/main/java/com/yunbao/common/bean/WishModel.java index e4429727d..e1bef642b 100644 --- a/common/src/main/java/com/yunbao/common/bean/WishModel.java +++ b/common/src/main/java/com/yunbao/common/bean/WishModel.java @@ -22,6 +22,12 @@ public class WishModel extends BaseModel { 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; @@ -103,4 +109,50 @@ public class WishModel extends BaseModel { this.createTime = createTime; return this; } + + public int getType() { + return type; + } + + public WishModel setType(int type) { + this.type = type; + return this; + } + + public int getGiftType() { + return giftType; + } + + public WishModel setGiftType(int giftType) { + this.giftType = giftType; + return this; + } + + public int getPrice() { + return price; + } + + public WishModel 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/event/LiveNewWishGiftEvent.java b/common/src/main/java/com/yunbao/common/event/LiveNewWishGiftEvent.java new file mode 100644 index 000000000..b0a6d1652 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveNewWishGiftEvent.java @@ -0,0 +1,17 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.GiftListModel; + +public class LiveNewWishGiftEvent extends BaseModel { + private GiftListModel model; + + public GiftListModel getModel() { + return model; + } + + public LiveNewWishGiftEvent setModel(GiftListModel model) { + this.model = model; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/event/LiveNewWishListEvent.java b/common/src/main/java/com/yunbao/common/event/LiveNewWishListEvent.java new file mode 100644 index 000000000..171bbf898 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveNewWishListEvent.java @@ -0,0 +1,27 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.GiftListModel; + +public class LiveNewWishListEvent extends BaseModel { + private GiftListModel model; + private int type = 0; + + public int getType() { + return type; + } + + public LiveNewWishListEvent setType(int type) { + this.type = type; + return this; + } + + public GiftListModel getModel() { + return model; + } + + public LiveNewWishListEvent setModel(GiftListModel model) { + this.model = model; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishGiftFragment.java b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishGiftFragment.java new file mode 100644 index 000000000..37c5fe10d --- /dev/null +++ b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishGiftFragment.java @@ -0,0 +1,136 @@ +package com.yunbao.common.fragment; + +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.tabs.TabLayout; +import com.shencoder.pagergridlayoutmanager.PagerGridLayoutManager; +import com.yunbao.common.R; +import com.yunbao.common.adapter.LiveNewWishGiftAdapter; +import com.yunbao.common.bean.GiftListModel; +import com.yunbao.common.utils.DpUtil; + +import java.io.Serializable; +import java.util.List; + +public class LiveNewWishGiftFragment extends BaseFragment { + private List giftListModels; + private RecyclerView giftList; + private LiveNewWishGiftAdapter liveNewWishGiftAdapter; + private TabLayout wishTab; + + @Override + public View createView(LayoutInflater inflater, ViewGroup container) { + return inflater.inflate(R.layout.view_live_new_wish_gitf, container, false); + } + + @Override + protected void initVariables(Bundle bundle) { + giftListModels = (List) bundle.getSerializable("GiftList"); + for (GiftListModel model : giftListModels) { + Log.e("LiveNewWishGiftFragment", model.getName()); + } +// + } + + @Override + protected void initViews(Bundle savedInstanceState, View contentView) { + wishTab = contentView.findViewById(R.id.wish_tab); + wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT); + wishTab.setFocusableInTouchMode(false); + + //计算总页数 + int pagerCount = giftListModels.size() / 8; + if (giftListModels.size() % 8 != 0) { + ++pagerCount; + } + + if (pagerCount > 1) { + for (int i = 0; i < pagerCount; i++) { + TextView wishItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.view_tablaout_wish_item, null, false); + TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i); + + wishTab.addTab(tab, i == 0); + } + ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0); + //设置边距,tab宽 + for (int i = 0; i < tabs.getChildCount(); i++) { + View tab = tabs.getChildAt(i); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams(); + layoutParams.rightMargin = DpUtil.dp2px(5); + layoutParams.leftMargin = DpUtil.dp2px(5); + layoutParams.width = DpUtil.dp2px(6); + layoutParams.height = DpUtil.dp2px(6); + tab.setLayoutParams(layoutParams); + wishTab.requestLayout(); + } + wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + View customView = tab.getCustomView(); + customView.setSelected(true); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + View customView = tab.getCustomView(); + customView.setSelected(false); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + } else { + wishTab.setVisibility(View.GONE); + } + + giftList = contentView.findViewById(R.id.gift_list); + liveNewWishGiftAdapter = new LiveNewWishGiftAdapter(giftListModels); + PagerGridLayoutManager layoutManager = new PagerGridLayoutManager( /*rows*/2, + /*columns*/ 4, + /*PagerGridLayoutManager.VERTICAL*/PagerGridLayoutManager.HORIZONTAL, + /*reverseLayout*/ false); + layoutManager.setHandlingSlidingConflictsEnabled(true); + giftList.setLayoutManager(layoutManager); + giftList.setAdapter(liveNewWishGiftAdapter); + layoutManager.setPagerChangedListener(new PagerGridLayoutManager.PagerChangedListener() { + @Override + public void onPagerCountChanged(int pagerCount) { + Log.e("LiveNewWishGiftFragment", "onPagerCountChanged-pagerCount:" + pagerCount); + + } + + @Override + public void onPagerIndexSelected(int prePagerIndex, int currentPagerIndex) { + Log.e("LiveNewWishGiftFragment", "onPagerIndexSelected-prePagerIndex " + prePagerIndex + ",currentPagerIndex:" + currentPagerIndex); + if (wishTab.getVisibility() == View.VISIBLE) + wishTab.getTabAt(currentPagerIndex).select(); + + + } + }); + } + + @Override + protected void loadData() { + + } + + public static LiveNewWishGiftFragment newInstance(List giftListModels) { + LiveNewWishGiftFragment searchRecommendFragment = new LiveNewWishGiftFragment(); + Bundle bundle = new Bundle(); + bundle.putSerializable("GiftList", (Serializable) giftListModels); + searchRecommendFragment.setArguments(bundle); + return searchRecommendFragment; + } +} diff --git a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java new file mode 100644 index 000000000..19be6caa8 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java @@ -0,0 +1,84 @@ +package com.yunbao.common.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +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.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.LiveNewWishGiftPopup; + +public class LiveNewWishListFragment extends BaseFragment { + private int type = 0; + private RecyclerView wishList; + private LiveNewWishAdapter liveNewWishAdapter; + private ImageView imageView2; + + @Override + public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) { + return layoutInflater.inflate(R.layout.view_live_new_wish, viewGroup, false); + } + + @Override + protected void initVariables(Bundle bundle) { + type = bundle.getInt("type", 0); + + } + + @Override + protected void initViews(Bundle savedInstanceState, View contentView) { + wishList = contentView.findViewById(R.id.wish_list); + imageView2 = contentView.findViewById(R.id.imageView2); + liveNewWishAdapter = new LiveNewWishAdapter(); + wishList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + wishList.setAdapter(liveNewWishAdapter); + imageView2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + new XPopup.Builder(getContext()) + .enableDrag(false) + .asCustom(new LiveNewWishGiftPopup(getActivity(), type)) + .show(); + } + }); + } + + @Override + protected void loadData() { + LiveNetManager.get(getContext()).getWishlistV2(new HttpCallback() { + @Override + public void onSuccess(WishListModel data) { + liveNewWishAdapter.addData(data.getWishList(), type); + } + + @Override + public void onError(String error) { + ToastUtil.show(R.string.net_error); + } + }); + } + + public static LiveNewWishListFragment newInstance(int type) { + LiveNewWishListFragment searchRecommendFragment = new LiveNewWishListFragment(); + Bundle bundle = new Bundle(); + bundle.putInt("type", type); + + searchRecommendFragment.setArguments(bundle); + return searchRecommendFragment; + } + + public void addGiftListModel(WishModel model) { + liveNewWishAdapter.addGiftListModel(model); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 92857c5f6..81ac29815 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -37,6 +37,9 @@ import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.VipModel; +import com.yunbao.common.bean.WishListGiftConfModel; +import com.yunbao.common.bean.WishListModel; +import com.yunbao.common.bean.WishListModel2; import java.util.List; import java.util.Map; @@ -636,4 +639,37 @@ public interface PDLiveApi { Observable> delContactMsg( @Query("msgId") int msgId ); + + /** + * 获取心愿单配置 + * + * @return + */ + @GET("/api/public/?service=Guide.getWishlistV2") + Observable>> getWishlistV2(); + + /** + * 获取礼物配置 + * + * @param type 1日心愿单,2周,3月,4季度 + * @return + */ + @GET("/api/public/?service=Guide.getWishListGiftConf") + Observable> getWishListGiftConf( + @Query("type") int type + ); + + /** + * 设置心愿单 + * + * @param type 1日心愿单,2周,3月,4季度 + * @param list 列表json数据 + * @return + */ + @GET("/api/public/?service=Guide.setWishlistV2") + Observable> setWishlistV2( + @Query("type") int type, + @Query("list") String list + ); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 522470167..31ce3ba8b 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -35,6 +35,9 @@ import com.yunbao.common.bean.RankPkInfoBean; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.VipModel; +import com.yunbao.common.bean.WishListGiftConfModel; +import com.yunbao.common.bean.WishListModel; +import com.yunbao.common.bean.WishListModel2; import com.yunbao.common.http.API; import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.CheckLiveCallBack; @@ -1287,6 +1290,55 @@ public class LiveNetManager { }).isDisposed(); } + /** + * 获取心愿单配置 + * + * @param callback + */ + public void getWishlistV2(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getWishlistV2() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo().get(0)); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + + public void getWishListGiftConf(int type, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getWishListGiftConf(type) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel wishListGiftConfModelResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/utils/WordsTypeUtil.java b/common/src/main/java/com/yunbao/common/utils/WordsTypeUtil.java index 84d7e87e2..0598af1c0 100644 --- a/common/src/main/java/com/yunbao/common/utils/WordsTypeUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/WordsTypeUtil.java @@ -33,4 +33,30 @@ public class WordsTypeUtil { } return changeText; } + + /** + * @param {*} num + * @returns ---汉字 + */ +// 转换数字为大写 + public static String numberConvertToUppercase(int number) { + String[] upperCaseNumber = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}; + int length = String.valueOf(number).length(); + if (length == 1) { + return upperCaseNumber[number]; + } else if (length == 2) { + if (number == 10) { + return upperCaseNumber[number]; + } else if (number > 10 && number < 20) { + return upperCaseNumber[10] + upperCaseNumber[number - 10]; + } else { + int num1 = number / 10; + int num2 = number - (num1 * 10); + return upperCaseNumber[num1] + upperCaseNumber[10] + upperCaseNumber[num2]; + } + } else { + return String.valueOf(number); + } + + } } diff --git a/common/src/main/java/com/yunbao/common/views/DayWishItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/DayWishItemViewHolder.java new file mode 100644 index 000000000..335b71651 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/DayWishItemViewHolder.java @@ -0,0 +1,106 @@ +package com.yunbao.common.views; + +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.WishModel; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.WordsTypeUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +/** + * 日心愿单 + */ +public class DayWishItemViewHolder extends RecyclerView.ViewHolder { + private TextView wishTab, wishlistName, wishlistProgress, wishlistNum, wishlistNum2, subtraction, addition; + private ImageView wishIcon; + private FrameLayout wishIconBg, tabBg,iconCancel; + private ProgressBar progressBar; + + public DayWishItemViewHolder(@NonNull View itemView) { + super(itemView); + wishTab = itemView.findViewById(R.id.wish_tab); + wishIcon = itemView.findViewById(R.id.wish_icon); + tabBg = itemView.findViewById(R.id.tab_bg); + wishIconBg = itemView.findViewById(R.id.wish_icon_bg); + iconCancel = itemView.findViewById(R.id.icon_cancel); + wishlistName = itemView.findViewById(R.id.wishlist_name); + progressBar = itemView.findViewById(R.id.progressBar); + wishlistProgress = itemView.findViewById(R.id.wishlist_progress); + wishlistNum = itemView.findViewById(R.id.wishlist_num); + wishlistNum2 = itemView.findViewById(R.id.wishlist_num2); + subtraction = itemView.findViewById(R.id.subtraction); + addition = itemView.findViewById(R.id.addition); + } + + public void steDayWishData(WishModel model, int index, DayWishItemListener listener) { + if (model != null) { + itemView.findViewById(R.id.hind_layout).setVisibility(View.VISIBLE); + itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.VISIBLE); + itemView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE); + iconCancel.setVisibility(View.VISIBLE); + wishTab.setVisibility(View.VISIBLE); + wishlistName.setVisibility(View.VISIBLE); + wishTab.setText(String.format(itemView.getContext().getString(R.string.wish_number), WordsTypeUtil.numberConvertToUppercase(index + 1))); + ImgLoader.display(itemView.getContext(), model.getWishlistIcon(), wishIcon); + tabBg.setBackgroundResource(R.mipmap.bg_day_wish); + wishIconBg.setBackgroundResource(R.mipmap.background_wish_item); + wishlistName.setText(model.getWishlistName()); + progressBar.setMax(model.wishProgress()); + progressBar.setProgress(model.wishCurrent());//当前进度 + wishlistProgress.setText(model.getWishlistProgress()); + wishlistNum.setText(String.format("/%s", model.getWishlistNum())); + wishlistNum2.setText(String.format("x%s", model.getWishlistNum())); + ViewClicksAntiShake.clicksAntiShake(iconCancel, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (listener != null) { + listener.onDelete(index); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(addition, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + int number = model.wishProgress(); + model.setWishlistNum(String.valueOf(number + 1)); + if (listener != null) { + listener.onUpdate(model, index); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(subtraction, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + int number = model.wishProgress(); + model.setWishlistNum(String.valueOf(number - 1)); + if (listener != null) { + listener.onUpdate(model, index); + } + } + }); + } else { + itemView.findViewById(R.id.hind_layout).setVisibility(View.GONE); + itemView.findViewById(R.id.progress_bar).setVisibility(View.GONE); + tabBg.setBackground(null); + wishTab.setVisibility(View.GONE); + wishlistName.setVisibility(View.GONE); + iconCancel.setVisibility(View.GONE); + itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.GONE); + + } + } + + public interface DayWishItemListener { + void onDelete(int index); + + void onUpdate(WishModel model, int index); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java new file mode 100644 index 000000000..dabec291e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java @@ -0,0 +1,182 @@ +package com.yunbao.common.views; + +import android.graphics.Color; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager2.widget.ViewPager2; + +import com.google.android.material.tabs.TabLayout; +import com.lxj.xpopup.core.BottomPopupView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.LiveNewWishListAdapter; +import com.yunbao.common.bean.GiftListModel; +import com.yunbao.common.bean.WishListGiftConfModel; +import com.yunbao.common.event.LiveNewWishGiftEvent; +import com.yunbao.common.event.LiveNewWishListEvent; +import com.yunbao.common.fragment.LiveNewWishGiftFragment; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + +public class LiveNewWishGiftPopup extends BottomPopupView { + private TabLayout wishTab; + private int type = 0; + private ViewPager2 fragmentViewpager; + private FragmentActivity mContext; + private ArrayList ViewList = new ArrayList<>(); //页卡视图集合 + private GiftListModel model = null; + private Button wishGitfButton; + + public LiveNewWishGiftPopup(@NonNull FragmentActivity context, int type) { + super(context); + this.type = type; + mContext = context; + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.dialog_live_new_wish_gitf; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + Bus.getOn(this); + initView(); + initDate(); + + } + + @Override + protected void onDismiss() { + super.onDismiss(); + Bus.getOff(this); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveNewWishGiftEvent(LiveNewWishGiftEvent event) { + model = event.getModel(); + Log.e("LiveNewWishGiftPopup", model.toString()); + } + + private void initView() { + fragmentViewpager = findViewById(R.id.context_layout); + wishGitfButton = findViewById(R.id.wish_gitf_button); + wishTab = findViewById(R.id.wish_tab); + wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT); + wishTab.setFocusableInTouchMode(false); + for (int i = 0; i < 3; i++) { + TextView wishItem = (TextView) LayoutInflater.from(getContext()) + .inflate(R.layout.view_tablaout_wish_item, null, false); + + switch (i) { + case 0: + wishItem.setText(R.string.live_gift); + wishItem.setTextColor(Color.parseColor("#FFBE41")); + break; + case 1: + wishItem.setText(R.string.aristocrat); + wishItem.setTextColor(Color.parseColor("#B6B6B6")); + break; + case 2: + wishItem.setText(R.string.live_guard); + wishItem.setTextColor(Color.parseColor("#B6B6B6")); + break; + } + TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i); + wishTab.addTab(tab, i == 0); + } + ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0); + //设置边距,tab宽 + for (int i = 0; i < tabs.getChildCount() - 1; i++) { + View tab = tabs.getChildAt(i); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams(); + layoutParams.setMarginEnd(DpUtil.dp2px(4)); + layoutParams.width = DpUtil.dp2px(58); + tab.setLayoutParams(layoutParams); + wishTab.requestLayout(); + } + wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + TextView customView = (TextView) tab.getCustomView(); + customView.setTextColor(Color.parseColor("#FFBE41")); + fragmentViewpager.setCurrentItem(tab.getId(), false); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + TextView customView = (TextView) tab.getCustomView(); + customView.setTextColor(Color.parseColor("#B6B6B6")); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + ViewClicksAntiShake.clicksAntiShake(wishGitfButton, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (model != null) { + Bus.get().post(new LiveNewWishListEvent() + .setModel(model) + .setType(type)); + } + dismiss(); + } + }); + } + + private void initDate() { + LiveNetManager.get(getContext()).getWishListGiftConf(type, new HttpCallback() { + @Override + public void onSuccess(WishListGiftConfModel data) { + List giftListModels = new ArrayList<>(); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + giftListModels.addAll(data.getGiftList()); + ViewList.add(LiveNewWishGiftFragment.newInstance(giftListModels)); + ViewList.add(LiveNewWishGiftFragment.newInstance(data.getNobleList())); + ViewList.add(LiveNewWishGiftFragment.newInstance(data.getGuardList())); + LiveNewWishListAdapter liveNewWishListAdapter = new LiveNewWishListAdapter(mContext, ViewList); + fragmentViewpager.setAdapter(liveNewWishListAdapter); + fragmentViewpager.setOffscreenPageLimit(1); //预加载页面数 + //禁止左右滑动,false为禁止 + fragmentViewpager.setUserInputEnabled(false); + } + + @Override + public void onError(String error) { + ToastUtil.show(R.string.net_error); + } + }); + + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftViewHolder.java b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftViewHolder.java new file mode 100644 index 000000000..624ec25a1 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftViewHolder.java @@ -0,0 +1,37 @@ +package com.yunbao.common.views; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.GiftListModel; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +/** + * 心愿礼物配置页面 + */ +public class LiveNewWishGiftViewHolder extends RecyclerView.ViewHolder { + private ImageView giftImg; + private TextView giftName; + + public LiveNewWishGiftViewHolder(@NonNull View itemView) { + super(itemView); + giftImg = itemView.findViewById(R.id.gift_img); + giftName = itemView.findViewById(R.id.gift_name); + } + + public void setData(GiftListModel model, ViewClicksAntiShake.ViewClicksCallBack callBack) { + ImgLoader.display(itemView.getContext(), model.getImg(), giftImg); + giftName.setText(model.getName()); + ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.wish_gift), callBack); + } + + public void onSelect(boolean select) { + itemView.findViewById(R.id.wish_gift).setSelected(select); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java new file mode 100644 index 000000000..10062e449 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java @@ -0,0 +1,171 @@ +package com.yunbao.common.views; + +import android.graphics.Color; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager2.widget.ViewPager2; + +import com.google.android.material.tabs.TabLayout; +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.event.LiveNewWishListEvent; +import com.yunbao.common.fragment.LiveNewWishListFragment; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DpUtil; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; + +/** + * 新版心愿单 + */ +public class LiveNewWishListPopup extends BottomPopupView { + private TabLayout wishTab; + private FragmentActivity mContext; + private ViewPager2 fragmentViewpager; + private ArrayList ViewList = new ArrayList<>(); //页卡视图集合 + + private LiveNewWishListFragment dayWishFragment, zhouXinFragment, lunarWishFragment, seasonalWishFragment; + + public LiveNewWishListPopup(@NonNull FragmentActivity context) { + super(context); + mContext = context; + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.dialog_live_new_wish_list; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + Bus.getOn(this); + initView(); + initDate(); + + } + + @Override + protected void onDismiss() { + Bus.getOff(this); + super.onDismiss(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveNewWishListEvent(LiveNewWishListEvent event) { + WishModel model = new WishModel(); + model.setId(event.getModel().getId()) + .setWishlistName(event.getModel().getName()) + .setWishlistIcon(event.getModel().getImg()) + .setWishlistNum("1") + .setWishlistProgress("0") + .setPrice(Integer.parseInt(event.getModel().getPrice())) + .setGiftType(Integer.parseInt(event.getModel().getGiftType())) + .setType(event.getType()); + switch (event.getType()) { + case 1: + dayWishFragment.addGiftListModel(model); + break; + case 2: + zhouXinFragment.addGiftListModel(model); + break; + case 3: + lunarWishFragment.addGiftListModel(model); + break; + case 4: + lunarWishFragment.addGiftListModel(model); + break; + } + } + + private void initView() { + fragmentViewpager = findViewById(R.id.context_layout); + wishTab = findViewById(R.id.wish_tab); + wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT); + wishTab.setFocusableInTouchMode(false); + dayWishFragment = LiveNewWishListFragment.newInstance(1); + zhouXinFragment = LiveNewWishListFragment.newInstance(2); + lunarWishFragment = LiveNewWishListFragment.newInstance(3); + seasonalWishFragment = LiveNewWishListFragment.newInstance(4); + ViewList.add(dayWishFragment); + ViewList.add(zhouXinFragment); + ViewList.add(lunarWishFragment); + ViewList.add(seasonalWishFragment); + + LiveNewWishListAdapter liveNewWishListAdapter = new LiveNewWishListAdapter(mContext, ViewList); + fragmentViewpager.setAdapter(liveNewWishListAdapter); + + fragmentViewpager.setOffscreenPageLimit(1); //预加载页面数 + + //禁止左右滑动,false为禁止 + fragmentViewpager.setUserInputEnabled(false); + + for (int i = 0; i < 4; i++) { + TextView wishItem = (TextView) LayoutInflater.from(getContext()) + .inflate(R.layout.view_tablaout_wish_item, null, false); + switch (i) { + case 0: + wishItem.setText(R.string.day_wish); + break; + case 1: + wishItem.setText(R.string.zhou_xin); + break; + case 2: + wishItem.setText(R.string.lunar_wish); + break; + case 3: + wishItem.setText(R.string.seasonal_wish); + break; + } + TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i); + wishTab.addTab(tab, i == 0); + } + ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0); + //设置边距,tab宽 + for (int i = 0; i < tabs.getChildCount() - 1; i++) { + View tab = tabs.getChildAt(i); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams(); + layoutParams.setMarginEnd(DpUtil.dp2px(6)); + layoutParams.width = DpUtil.dp2px(83); + tab.setLayoutParams(layoutParams); + wishTab.requestLayout(); + } + wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + View customView = tab.getCustomView(); + customView.setSelected(true); + fragmentViewpager.setCurrentItem(tab.getId(), false); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + View customView = tab.getCustomView(); + customView.setSelected(false); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + } + + private void initDate() { + + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java new file mode 100644 index 000000000..37c98a2e8 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java @@ -0,0 +1,12 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class LunarWishItemViewHolder extends RecyclerView.ViewHolder { + public LunarWishItemViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/SeasonalWishItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/SeasonalWishItemViewHolder.java new file mode 100644 index 000000000..78fa969f7 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/SeasonalWishItemViewHolder.java @@ -0,0 +1,12 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class SeasonalWishItemViewHolder extends RecyclerView.ViewHolder { + public SeasonalWishItemViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/WeekWishItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/WeekWishItemViewHolder.java new file mode 100644 index 000000000..ab485f299 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/WeekWishItemViewHolder.java @@ -0,0 +1,12 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class WeekWishItemViewHolder extends RecyclerView.ViewHolder { + public WeekWishItemViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/res/drawable/background_wilsh_gitf.xml b/common/src/main/res/drawable/background_wilsh_gitf.xml new file mode 100644 index 000000000..2b0866a0b --- /dev/null +++ b/common/src/main/res/drawable/background_wilsh_gitf.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/background_wilsh_tab.xml b/common/src/main/res/drawable/background_wilsh_tab.xml new file mode 100644 index 000000000..5896ba73f --- /dev/null +++ b/common/src/main/res/drawable/background_wilsh_tab.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/background_wilsh_tab_gift.xml b/common/src/main/res/drawable/background_wilsh_tab_gift.xml new file mode 100644 index 000000000..f1c44f04b --- /dev/null +++ b/common/src/main/res/drawable/background_wilsh_tab_gift.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/background_wish_item.xml b/common/src/main/res/drawable/background_wish_item.xml new file mode 100644 index 000000000..6d72f922b --- /dev/null +++ b/common/src/main/res/drawable/background_wish_item.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_wish_gitf_button.xml b/common/src/main/res/drawable/bg_wish_gitf_button.xml new file mode 100644 index 000000000..36083ce91 --- /dev/null +++ b/common/src/main/res/drawable/bg_wish_gitf_button.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_xyd.png b/common/src/main/res/drawable/bg_xyd.png similarity index 100% rename from live/src/main/res/drawable/bg_xyd.png rename to common/src/main/res/drawable/bg_xyd.png diff --git a/live/src/main/res/drawable/bg_xyd_add_item.png b/common/src/main/res/drawable/bg_xyd_add_item.png similarity index 100% rename from live/src/main/res/drawable/bg_xyd_add_item.png rename to common/src/main/res/drawable/bg_xyd_add_item.png diff --git a/live/src/main/res/drawable/bg_xyd_button.png b/common/src/main/res/drawable/bg_xyd_button.png similarity index 100% rename from live/src/main/res/drawable/bg_xyd_button.png rename to common/src/main/res/drawable/bg_xyd_button.png diff --git a/live/src/main/res/drawable/bg_xyd_number.png b/common/src/main/res/drawable/bg_xyd_number.png similarity index 100% rename from live/src/main/res/drawable/bg_xyd_number.png rename to common/src/main/res/drawable/bg_xyd_number.png diff --git a/common/src/main/res/drawable/progress_wishlist2.xml b/common/src/main/res/drawable/progress_wishlist2.xml new file mode 100644 index 000000000..705c93b82 --- /dev/null +++ b/common/src/main/res/drawable/progress_wishlist2.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_live_new_wish_gitf.xml b/common/src/main/res/layout/dialog_live_new_wish_gitf.xml new file mode 100644 index 000000000..64196fb20 --- /dev/null +++ b/common/src/main/res/layout/dialog_live_new_wish_gitf.xml @@ -0,0 +1,44 @@ + + + + + + + +