心愿单完成
This commit is contained in:
@@ -9,6 +9,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.WishModel;
|
||||
import com.yunbao.common.event.LiveNewWishListCloseEvent;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.views.DayWishItemViewHolder;
|
||||
import com.yunbao.common.views.LunarWishItemViewHolder;
|
||||
import com.yunbao.common.views.SeasonalWishItemViewHolder;
|
||||
@@ -30,6 +32,21 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
public void addGiftListModel(WishModel model) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
|
||||
break;
|
||||
case 2:
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
|
||||
break;
|
||||
case 3:
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
|
||||
break;
|
||||
case 4:
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
|
||||
break;
|
||||
}
|
||||
|
||||
wishList.add(0, model);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@@ -66,12 +83,14 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
dayWishItemViewHolder.steDayWishData(wishList.get(position), position, new DayWishItemViewHolder.DayWishItemListener() {
|
||||
@Override
|
||||
public void onDelete(int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
|
||||
wishList.remove(index);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(WishModel model, int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
|
||||
wishList.remove(index);
|
||||
wishList.add(index, model);
|
||||
notifyItemChanged(index);
|
||||
@@ -82,12 +101,15 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
weekWishItemViewHolder.steWeekWishData(wishList.get(position), position, new WeekWishItemViewHolder.WeekWishItemListener() {
|
||||
@Override
|
||||
public void onDelete(int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
|
||||
wishList.remove(index);
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(WishModel model, int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
|
||||
wishList.remove(index);
|
||||
wishList.add(index, model);
|
||||
notifyItemChanged(index);
|
||||
@@ -98,12 +120,14 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
lunarWishItemViewHolder.steLunarWishData(wishList.get(position), position, new LunarWishItemViewHolder.LunarWishItemListener() {
|
||||
@Override
|
||||
public void onDelete(int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
|
||||
wishList.remove(index);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(WishModel model, int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
|
||||
wishList.remove(index);
|
||||
wishList.add(index, model);
|
||||
notifyItemChanged(index);
|
||||
@@ -114,12 +138,14 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
seasonalWishItemViewHolder.steSeasonalWish(wishList.get(position), position, new SeasonalWishItemViewHolder.SeasonalWishItemListener() {
|
||||
@Override
|
||||
public void onDelete(int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
|
||||
wishList.remove(index);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(WishModel model, int index) {
|
||||
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
|
||||
wishList.remove(index);
|
||||
wishList.add(index, model);
|
||||
notifyItemChanged(index);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunbao.common.event;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class LiveNewWishListCloseEvent extends BaseModel {
|
||||
private boolean dayWish = false;
|
||||
private boolean zhouXin = false;
|
||||
private boolean lunarWish = false;
|
||||
private boolean seasonalWish = false;
|
||||
|
||||
public boolean isDayWish() {
|
||||
return dayWish;
|
||||
}
|
||||
|
||||
public LiveNewWishListCloseEvent setDayWish(boolean dayWish) {
|
||||
this.dayWish = dayWish;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isZhouXin() {
|
||||
return zhouXin;
|
||||
}
|
||||
|
||||
public LiveNewWishListCloseEvent setZhouXin(boolean zhouXin) {
|
||||
this.zhouXin = zhouXin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isLunarWish() {
|
||||
return lunarWish;
|
||||
}
|
||||
|
||||
public LiveNewWishListCloseEvent setLunarWish(boolean lunarWish) {
|
||||
this.lunarWish = lunarWish;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSeasonalWish() {
|
||||
return seasonalWish;
|
||||
}
|
||||
|
||||
public LiveNewWishListCloseEvent setSeasonalWish(boolean seasonalWish) {
|
||||
this.seasonalWish = seasonalWish;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ public class LiveNewWishListEvent extends BaseModel {
|
||||
private GiftListModel model;
|
||||
private int type = 0;
|
||||
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ 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.event.LiveNewWishListCloseEvent;
|
||||
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.ToastUtil;
|
||||
import com.yunbao.common.views.LiveNewWishGiftPopup;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
@@ -58,25 +60,7 @@ public class LiveNewWishListFragment extends BaseFragment {
|
||||
.show();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(tvDone, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
List<WishModel> wishList = liveNewWishAdapter.getWishList();
|
||||
wishList.remove(wishList.size() - 1);
|
||||
LiveNetManager.get(getContext()).
|
||||
setWishlistV2(type, new Gson().toJson(wishList), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(R.string.net_error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(tvDone, () -> saveWish());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,4 +96,35 @@ public class LiveNewWishListFragment extends BaseFragment {
|
||||
List<WishModel> wishList = new ArrayList<>();
|
||||
liveNewWishAdapter.addData(wishList, type);
|
||||
}
|
||||
|
||||
public void saveWish() {
|
||||
List<WishModel> wishList = liveNewWishAdapter.getWishList();
|
||||
wishList.remove(wishList.size() - 1);
|
||||
LiveNetManager.get(getContext()).
|
||||
setWishlistV2(type, new Gson().toJson(wishList), 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import com.yunbao.common.R;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
public class HintCustomPopup extends CenterPopupView {
|
||||
private String title, contest;
|
||||
private String title, contest,openCancel,openOk;
|
||||
private TextView liveOpenCancel, liveOpenOk;
|
||||
|
||||
public HintCustomPopup(@NonNull Context context, String title, String contest) {
|
||||
super(context);
|
||||
@@ -23,6 +24,16 @@ public class HintCustomPopup extends CenterPopupView {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HintCustomPopup setLiveOpenCancel(String openCancel) {
|
||||
this.openCancel = openCancel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HintCustomPopup setLiveOpenOk(String openOk) {
|
||||
this.openOk = openOk;
|
||||
return this;
|
||||
}
|
||||
|
||||
// 返回自定义弹窗的布局
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
@@ -35,19 +46,23 @@ public class HintCustomPopup extends CenterPopupView {
|
||||
super.onCreate();
|
||||
TextView titleText = findViewById(R.id.title);
|
||||
TextView contestText = findViewById(R.id.contest);
|
||||
liveOpenCancel = findViewById(R.id.live_open_cancel);
|
||||
liveOpenOk = findViewById(R.id.live_open_ok);
|
||||
liveOpenOk.setText(openOk);
|
||||
liveOpenCancel.setText(openCancel);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
titleText.setText(title);
|
||||
}
|
||||
if (!TextUtils.isEmpty(contest)) {
|
||||
contestText.setText(contest);
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_ok), () -> {
|
||||
ViewClicksAntiShake.clicksAntiShake(liveOpenOk, () -> {
|
||||
if (callBack != null) {
|
||||
callBack.onSure();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_cancel), () -> {
|
||||
ViewClicksAntiShake.clicksAntiShake(liveOpenCancel, () -> {
|
||||
if (callBack != null) {
|
||||
callBack.onCancel();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ 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.LiveNewWishListCloseEvent;
|
||||
import com.yunbao.common.event.LiveNewWishListEvent;
|
||||
import com.yunbao.common.fragment.LiveNewWishListFragment;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
@@ -46,6 +47,11 @@ public class LiveNewWishListPopup extends BottomPopupView {
|
||||
private int type = 1;
|
||||
private TextView replacementWish;
|
||||
|
||||
private boolean dayWish;
|
||||
private boolean zhouXin;
|
||||
private boolean lunarWish;
|
||||
private boolean seasonalWish;
|
||||
|
||||
private LiveNewWishListFragment dayWishFragment, zhouXinFragment, lunarWishFragment, seasonalWishFragment;
|
||||
|
||||
public LiveNewWishListPopup(@NonNull FragmentActivity context) {
|
||||
@@ -69,12 +75,77 @@ public class LiveNewWishListPopup extends BottomPopupView {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (dayWish || zhouXin || lunarWish || seasonalWish) {
|
||||
saveWishDialog(true);
|
||||
return;
|
||||
}
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
private HintCustomPopup hintCustomPopup;
|
||||
|
||||
private void saveWishDialog(boolean isDismiss) {
|
||||
if (hintCustomPopup != null) return;
|
||||
|
||||
hintCustomPopup = new HintCustomPopup(
|
||||
getContext(),
|
||||
getContext().getString(R.string.replacement_reset_confirmed_cancel3),
|
||||
getContext().getString(R.string.replacement_reset_confirmed_cancel2))
|
||||
.setLiveOpenCancel(getContext().getString(R.string.replacement_reset_confirmed_cancel4))
|
||||
.setLiveOpenOk(getContext().getString(R.string.save))
|
||||
.setCallBack(new HintCustomPopup.HintCustomCallBack() {
|
||||
@Override
|
||||
public void onSure() {
|
||||
hintCustomPopup = null;
|
||||
if (dayWish) {
|
||||
dayWishFragment.saveWish();
|
||||
} else if (zhouXin) {
|
||||
zhouXinFragment.saveWish();
|
||||
} else if (lunarWish) {
|
||||
lunarWishFragment.saveWish();
|
||||
} else if (seasonalWish) {
|
||||
seasonalWishFragment.saveWish();
|
||||
}
|
||||
if (isDismiss) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
dayWish = false;
|
||||
zhouXin = false;
|
||||
lunarWish = false;
|
||||
seasonalWish = false;
|
||||
hintCustomPopup = null;
|
||||
if (isDismiss) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(hintCustomPopup)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
Bus.getOff(this);
|
||||
|
||||
super.onDismiss();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveNewWishListCloseEvent(LiveNewWishListCloseEvent event) {
|
||||
dayWish = event.isDayWish();
|
||||
zhouXin = event.isZhouXin();
|
||||
lunarWish = event.isLunarWish();
|
||||
seasonalWish = event.isSeasonalWish();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveNewWishListEvent(LiveNewWishListEvent event) {
|
||||
WishModel model = new WishModel();
|
||||
@@ -183,6 +254,9 @@ public class LiveNewWishListPopup extends BottomPopupView {
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
View customView = tab.getCustomView();
|
||||
customView.setSelected(false);
|
||||
if (dayWish || zhouXin || lunarWish || seasonalWish) {
|
||||
saveWishDialog(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,15 +269,20 @@ public class LiveNewWishListPopup extends BottomPopupView {
|
||||
switch (type) {
|
||||
case 1:
|
||||
dayWishFragment.clearGiftListModel();
|
||||
dayWish = false;
|
||||
break;
|
||||
case 2:
|
||||
zhouXinFragment.clearGiftListModel();
|
||||
zhouXin = false;
|
||||
break;
|
||||
case 3:
|
||||
lunarWishFragment.clearGiftListModel();
|
||||
lunarWish = false;
|
||||
|
||||
break;
|
||||
case 4:
|
||||
seasonalWishFragment.clearGiftListModel();
|
||||
seasonalWish = false;
|
||||
break;
|
||||
}
|
||||
List<WishModel> wishList = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user