diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java index bc987a6bf..293b173c7 100644 --- a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java @@ -34,6 +34,11 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter { notifyDataSetChanged(); } + public List getWishList() { + + return wishList; + } + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { diff --git a/common/src/main/java/com/yunbao/common/bean/WishListModel.java b/common/src/main/java/com/yunbao/common/bean/WishListModel.java index ed4409105..2cbc45b15 100644 --- a/common/src/main/java/com/yunbao/common/bean/WishListModel.java +++ b/common/src/main/java/com/yunbao/common/bean/WishListModel.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.List; public class WishListModel extends BaseModel { - @SerializedName("wishList") + @SerializedName(value = "wishList",alternate = {"wishlist"}) private List wishList = new ArrayList<>(); @SerializedName("img") private String img; 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 19be6caa8..e32712cef 100644 --- a/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/LiveNewWishListFragment.java @@ -9,6 +9,7 @@ import android.widget.ImageView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.yunbao.common.R; import com.yunbao.common.adapter.LiveNewWishAdapter; @@ -18,12 +19,16 @@ import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.LiveNewWishGiftPopup; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import java.util.ArrayList; +import java.util.List; public class LiveNewWishListFragment extends BaseFragment { private int type = 0; private RecyclerView wishList; private LiveNewWishAdapter liveNewWishAdapter; - private ImageView imageView2; + private ImageView imageView2, tvDone; @Override public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) { @@ -40,6 +45,7 @@ public class LiveNewWishListFragment extends BaseFragment { protected void initViews(Bundle savedInstanceState, View contentView) { wishList = contentView.findViewById(R.id.wish_list); imageView2 = contentView.findViewById(R.id.imageView2); + tvDone = contentView.findViewById(R.id.tvDone); liveNewWishAdapter = new LiveNewWishAdapter(); wishList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); wishList.setAdapter(liveNewWishAdapter); @@ -52,13 +58,33 @@ public class LiveNewWishListFragment extends BaseFragment { .show(); } }); + ViewClicksAntiShake.clicksAntiShake(tvDone, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + List wishList = liveNewWishAdapter.getWishList(); + wishList.remove(wishList.size() - 1); + 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); + } + }); + } + }); } @Override protected void loadData() { - LiveNetManager.get(getContext()).getWishlistV2(new HttpCallback() { + LiveNetManager.get(getContext()).getWishlistV2(type, new HttpCallback() { @Override public void onSuccess(WishListModel data) { + liveNewWishAdapter.addData(data.getWishList(), type); } @@ -81,4 +107,9 @@ public class LiveNewWishListFragment extends BaseFragment { public void addGiftListModel(WishModel model) { liveNewWishAdapter.addGiftListModel(model); } + + public void clearGiftListModel() { + List wishList = new ArrayList<>(); + liveNewWishAdapter.addData(wishList, type); + } } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 81ac29815..c6ff26e03 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -646,7 +646,7 @@ public interface PDLiveApi { * @return */ @GET("/api/public/?service=Guide.getWishlistV2") - Observable>> getWishlistV2(); + Observable>> getWishlistV2( @Query("type") int type); /** * 获取礼物配置 @@ -667,7 +667,7 @@ public interface PDLiveApi { * @return */ @GET("/api/public/?service=Guide.setWishlistV2") - Observable> setWishlistV2( + Observable>> setWishlistV2( @Query("type") int type, @Query("list") String list ); diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 31ce3ba8b..fa7cd900f 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -4,7 +4,6 @@ import android.content.Context; import android.text.TextUtils; import android.util.Log; -import com.alibaba.fastjson.JSONObject; import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.bean.ActiveModel; @@ -37,7 +36,6 @@ import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; -import com.yunbao.common.bean.WishListModel2; import com.yunbao.common.http.API; import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.CheckLiveCallBack; @@ -52,7 +50,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; -import retrofit2.http.Query; /** @@ -1295,9 +1292,9 @@ public class LiveNetManager { * * @param callback */ - public void getWishlistV2(HttpCallback callback) { + public void getWishlistV2(int type, HttpCallback callback) { API.get().pdLiveApi(mContext) - .getWishlistV2() + .getWishlistV2(type) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer>>() { @@ -1339,6 +1336,28 @@ public class LiveNetManager { }).isDisposed(); } + public void setWishlistV2(int type, String list, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .setWishlistV2(type, list) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> stringResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(stringResponseModel.getData().getInfo().get(0)); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ 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 10062e449..e352f75bb 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveNewWishListPopup.java @@ -19,8 +19,10 @@ 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.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -35,6 +37,8 @@ public class LiveNewWishListPopup extends BottomPopupView { private FragmentActivity mContext; private ViewPager2 fragmentViewpager; private ArrayList ViewList = new ArrayList<>(); //页卡视图集合 + private int type = 1; + private TextView replacementWish; private LiveNewWishListFragment dayWishFragment, zhouXinFragment, lunarWishFragment, seasonalWishFragment; @@ -68,10 +72,11 @@ public class LiveNewWishListPopup extends BottomPopupView { @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveNewWishListEvent(LiveNewWishListEvent event) { WishModel model = new WishModel(); - model.setId(event.getModel().getId()) + model.setLid(event.getModel().getId()) .setWishlistName(event.getModel().getName()) .setWishlistIcon(event.getModel().getImg()) .setWishlistNum("1") + .setLuid("" + IMLoginManager.get(mContext).getUserInfo().getId()) .setWishlistProgress("0") .setPrice(Integer.parseInt(event.getModel().getPrice())) .setGiftType(Integer.parseInt(event.getModel().getGiftType())) @@ -87,7 +92,7 @@ public class LiveNewWishListPopup extends BottomPopupView { lunarWishFragment.addGiftListModel(model); break; case 4: - lunarWishFragment.addGiftListModel(model); + seasonalWishFragment.addGiftListModel(model); break; } } @@ -95,6 +100,7 @@ public class LiveNewWishListPopup extends BottomPopupView { private void initView() { fragmentViewpager = findViewById(R.id.context_layout); wishTab = findViewById(R.id.wish_tab); + replacementWish = findViewById(R.id.replacement_wish); wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT); wishTab.setFocusableInTouchMode(false); dayWishFragment = LiveNewWishListFragment.newInstance(1); @@ -150,6 +156,21 @@ public class LiveNewWishListPopup extends BottomPopupView { View customView = tab.getCustomView(); customView.setSelected(true); fragmentViewpager.setCurrentItem(tab.getId(), false); + type = tab.getId() + 1; + switch (type){ + case 1: + replacementWish.setText(R.string.replacement_wish_day); + break; + case 2: + replacementWish.setText(R.string.replacement_wish_zhou); + break; + case 3: + replacementWish.setText(R.string.replacement_wish_lunar); + break; + case 4: + replacementWish.setText(R.string.replacement_wish_seasonal); + break; + } } @Override @@ -163,6 +184,25 @@ 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; + } + } + }); } private void initDate() { diff --git a/common/src/main/res/drawable/background_wish_replacement.xml b/common/src/main/res/drawable/background_wish_replacement.xml new file mode 100644 index 000000000..a60aedd00 --- /dev/null +++ b/common/src/main/res/drawable/background_wish_replacement.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_live_new_wish_list.xml b/common/src/main/res/layout/dialog_live_new_wish_list.xml index 2ec776a54..aa4dca25f 100644 --- a/common/src/main/res/layout/dialog_live_new_wish_list.xml +++ b/common/src/main/res/layout/dialog_live_new_wish_list.xml @@ -1,5 +1,5 @@ - + android:layout_height="match_parent" + android:layout_below="@+id/wish_tab" /> - \ No newline at end of file + + + \ 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 05f63cac6..2eb863022 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1096,6 +1096,10 @@ 貴族 確定 女神說 + 重置心願:日 + 重置心願:周 + 重置心願:月 + 重置心願:季