修改生成心愿单

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,40 +107,46 @@ 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) {
WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class); if (model!=null){
wishList2.add(model2); 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<String>() {
@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<String>() {
@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;
}
} }
} }

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();