From d1d8054c0112bfffe9f8d73a23bc661c36f6fc6c Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 30 Mar 2023 17:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=83=E6=84=BF=E5=8D=95=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/views/LiveNewWishGiftPopup.java | 13 +--- .../common/views/LiveNewWishListPopup.java | 58 +++++++++----- .../views/ReplacementHintCustomPopup.java | 72 +++++++++++++++++ .../layout/replacement_hint_custom_popup.xml | 78 +++++++++++++++++++ common/src/main/res/values/strings.xml | 4 + 5 files changed, 194 insertions(+), 31 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/views/ReplacementHintCustomPopup.java create mode 100644 common/src/main/res/layout/replacement_hint_custom_popup.xml diff --git a/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java index dabec291e..56d53dc8f 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishGiftPopup.java @@ -152,17 +152,8 @@ public class LiveNewWishGiftPopup extends BottomPopupView { 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.getGiftList())); ViewList.add(LiveNewWishGiftFragment.newInstance(data.getNobleList())); ViewList.add(LiveNewWishGiftFragment.newInstance(data.getGuardList())); LiveNewWishListAdapter liveNewWishListAdapter = new LiveNewWishListAdapter(mContext, ViewList); 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 e352f75bb..d7f54cfd1 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java @@ -13,21 +13,27 @@ import androidx.fragment.app.FragmentActivity; import androidx.viewpager2.widget.ViewPager2; import com.google.android.material.tabs.TabLayout; +import com.google.gson.Gson; +import com.lxj.xpopup.XPopup; 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.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; 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; /** * 新版心愿单 @@ -157,7 +163,7 @@ public class LiveNewWishListPopup extends BottomPopupView { customView.setSelected(true); fragmentViewpager.setCurrentItem(tab.getId(), false); type = tab.getId() + 1; - switch (type){ + switch (type) { case 1: replacementWish.setText(R.string.replacement_wish_day); break; @@ -184,25 +190,37 @@ public class LiveNewWishListPopup extends BottomPopupView { } }); - ViewClicksAntiShake.clicksAntiShake(replacementWish, new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - switch (type){ - case 1: - dayWishFragment.clearGiftListModel(); - break; - case 2: - zhouXinFragment.clearGiftListModel(); - break; - case 3: - lunarWishFragment.clearGiftListModel(); - break; - case 4: - seasonalWishFragment.clearGiftListModel(); - break; - } - } - }); + ViewClicksAntiShake.clicksAntiShake(replacementWish, () -> new XPopup.Builder(getContext()) + .asCustom(new ReplacementHintCustomPopup(getContext(), type, type -> { + switch (type) { + case 1: + dayWishFragment.clearGiftListModel(); + break; + case 2: + zhouXinFragment.clearGiftListModel(); + break; + case 3: + lunarWishFragment.clearGiftListModel(); + break; + case 4: + seasonalWishFragment.clearGiftListModel(); + break; + } + List wishList = new ArrayList<>(); + LiveNetManager.get(getContext()). + setWishlistV2(type, new Gson().toJson(wishList), new HttpCallback() { + @Override + public void onSuccess(String data) { + ToastUtil.show(data); + } + + @Override + public void onError(String error) { + ToastUtil.show(R.string.net_error); + } + }); + })) + .show()); } private void initDate() { diff --git a/common/src/main/java/com/yunbao/common/views/ReplacementHintCustomPopup.java b/common/src/main/java/com/yunbao/common/views/ReplacementHintCustomPopup.java new file mode 100644 index 000000000..cc5e93da2 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/ReplacementHintCustomPopup.java @@ -0,0 +1,72 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.R; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +/** + * 心愿单重置、保存提示 + */ +public class ReplacementHintCustomPopup extends CenterPopupView { + private int type = 0; + private TextView wishTab; + private ReplacementHintCallBack callBack; + + public ReplacementHintCustomPopup(@NonNull Context context, int type, ReplacementHintCallBack callBack) { + super(context); + this.type = type; + this.callBack = callBack; + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.replacement_hint_custom_popup; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + wishTab = findViewById(R.id.wish_tab); + switch (type) { + case 1: + wishTab.setText(String.format("【%s】", getContext().getString(R.string.day_wish))); + + break; + case 2: + wishTab.setText(String.format("【%s】", getContext().getString(R.string.zhou_xin))); + break; + case 3: + wishTab.setText(String.format("【%s】", getContext().getString(R.string.lunar_wish))); + break; + case 4: + wishTab.setText(String.format("【%s】", getContext().getString(R.string.seasonal_wish))); + break; + } + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_cancel), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (callBack != null) { + callBack.onReplacement(type); + } + dismiss(); + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_ok), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + dismiss(); + } + }); + } + + public interface ReplacementHintCallBack { + void onReplacement(int type); + } +} diff --git a/common/src/main/res/layout/replacement_hint_custom_popup.xml b/common/src/main/res/layout/replacement_hint_custom_popup.xml new file mode 100644 index 000000000..87f2ff7d6 --- /dev/null +++ b/common/src/main/res/layout/replacement_hint_custom_popup.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 2eb863022..ecf31dd7a 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1100,6 +1100,10 @@ 重置心願:周 重置心願:月 重置心願:季 + 是否確定重置 + 重置後將會清空當前心願單列表\n無論心願單是否完成 + 確定重置 + 返回列表