diff --git a/common/src/main/java/com/yunbao/common/event/PopupViewDismissEvent.java b/common/src/main/java/com/yunbao/common/event/PopupViewDismissEvent.java new file mode 100644 index 000000000..736875aa5 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/PopupViewDismissEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class PopupViewDismissEvent extends BaseModel { +} 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 b42186922..20ee6ddd7 100644 --- a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java @@ -17,6 +17,7 @@ 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.event.PopupViewDismissEvent; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.Bus; @@ -61,7 +62,13 @@ public class LiveNewWishListFragment extends BaseFragment { .show(); } }); - ViewClicksAntiShake.clicksAntiShake(tvDone, () -> saveWish()); + ViewClicksAntiShake.clicksAntiShake(tvDone, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + saveWish(); + Bus.get().post(new PopupViewDismissEvent()); + } + }); } @Override @@ -100,40 +107,46 @@ public class LiveNewWishListFragment extends BaseFragment { public void saveWish() { List wishList = liveNewWishAdapter.getWishList(); - wishList.remove(wishList.size() - 1); List wishList2 = new ArrayList<>(); Gson gson = new Gson(); for (WishModel model : wishList) { - WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class); - wishList2.add(model2); + if (model!=null){ + WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class); + wishList2.add(model2); + } + + } + if (wishList2.size() == 0) { + Bus.get().post(new PopupViewDismissEvent()); + } else { + LiveNetManager.get(getContext()). + setWishlistV2(type, gson.toJson(wishList2), new HttpCallback() { + @Override + public void onSuccess(String data) { + + } + + @Override + public void onError(String error) { + ToastUtil.show(R.string.net_error); + } + }); + switch (type) { + case 1: + Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(false)); + break; + case 2: + Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(false)); + break; + case 3: + Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(false)); + break; + case 4: + Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(false)); + break; + } } - LiveNetManager.get(getContext()). - setWishlistV2(type, gson.toJson(wishList2), new HttpCallback() { - @Override - public void onSuccess(String data) { - ToastUtil.show(data); - } - - @Override - public void onError(String error) { - ToastUtil.show(R.string.net_error); - } - }); - switch (type) { - case 1: - Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(false)); - break; - case 2: - Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(false)); - break; - case 3: - Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(false)); - break; - case 4: - Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(false)); - break; - } } } 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 e1303d6ee..c532a3581 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java @@ -24,6 +24,7 @@ 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.event.PopupViewDismissEvent; import com.yunbao.common.fragment.LiveNewWishListFragment; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; @@ -146,6 +147,11 @@ public class LiveNewWishListPopup extends BottomPopupView { super.onDismiss(); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onPopupViewDismissEvent(PopupViewDismissEvent event) { + dismiss(); + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveNewWishListCloseEvent(LiveNewWishListCloseEvent event) { dayWish = event.isDayWish();