修改生成心愿单

This commit is contained in:
18401019693 2023-04-10 13:30:47 +08:00
parent d50c56bbb2
commit 19c0c8c6e7
3 changed files with 55 additions and 30 deletions

View File

@ -0,0 +1,6 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class PopupViewDismissEvent extends BaseModel {
}

View File

@ -17,6 +17,7 @@ import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.WishModel2; import com.yunbao.common.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent; import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.event.PopupViewDismissEvent;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
@ -61,7 +62,13 @@ public class LiveNewWishListFragment extends BaseFragment {
.show(); .show();
} }
}); });
ViewClicksAntiShake.clicksAntiShake(tvDone, () -> saveWish()); ViewClicksAntiShake.clicksAntiShake(tvDone, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
saveWish();
Bus.get().post(new PopupViewDismissEvent());
}
});
} }
@Override @Override
@ -100,20 +107,23 @@ public class LiveNewWishListFragment extends BaseFragment {
public void saveWish() { public void saveWish() {
List<WishModel> wishList = liveNewWishAdapter.getWishList(); List<WishModel> wishList = liveNewWishAdapter.getWishList();
wishList.remove(wishList.size() - 1);
List<WishModel2> wishList2 = new ArrayList<>(); List<WishModel2> wishList2 = new ArrayList<>();
Gson gson = new Gson(); Gson gson = new Gson();
for (WishModel model : wishList) { for (WishModel model : wishList) {
if (model!=null){
WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class); WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class);
wishList2.add(model2); wishList2.add(model2);
} }
}
if (wishList2.size() == 0) {
Bus.get().post(new PopupViewDismissEvent());
} else {
LiveNetManager.get(getContext()). LiveNetManager.get(getContext()).
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() { setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
ToastUtil.show(data);
} }
@Override @Override
@ -136,4 +146,7 @@ public class LiveNewWishListFragment extends BaseFragment {
break; break;
} }
} }
}
} }

View File

@ -24,6 +24,7 @@ import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.WishModel2; import com.yunbao.common.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent; import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.event.LiveNewWishListEvent; import com.yunbao.common.event.LiveNewWishListEvent;
import com.yunbao.common.event.PopupViewDismissEvent;
import com.yunbao.common.fragment.LiveNewWishListFragment; import com.yunbao.common.fragment.LiveNewWishListFragment;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
@ -146,6 +147,11 @@ public class LiveNewWishListPopup extends BottomPopupView {
super.onDismiss(); super.onDismiss();
} }
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPopupViewDismissEvent(PopupViewDismissEvent event) {
dismiss();
}
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveNewWishListCloseEvent(LiveNewWishListCloseEvent event) { public void onLiveNewWishListCloseEvent(LiveNewWishListCloseEvent event) {
dayWish = event.isDayWish(); dayWish = event.isDayWish();