日心愿单重置
This commit is contained in:
parent
70a91fedf3
commit
5095de3c43
@ -34,6 +34,11 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<WishModel> getWishList() {
|
||||
|
||||
return wishList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -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<WishModel> wishList = new ArrayList<>();
|
||||
@SerializedName("img")
|
||||
private String img;
|
||||
|
@ -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<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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadData() {
|
||||
LiveNetManager.get(getContext()).getWishlistV2(new HttpCallback<WishListModel>() {
|
||||
LiveNetManager.get(getContext()).getWishlistV2(type, new HttpCallback<WishListModel>() {
|
||||
@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<WishModel> wishList = new ArrayList<>();
|
||||
liveNewWishAdapter.addData(wishList, type);
|
||||
}
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ public interface PDLiveApi {
|
||||
* @return
|
||||
*/
|
||||
@GET("/api/public/?service=Guide.getWishlistV2")
|
||||
Observable<ResponseModel<List<WishListModel>>> getWishlistV2();
|
||||
Observable<ResponseModel<List<WishListModel>>> getWishlistV2( @Query("type") int type);
|
||||
|
||||
/**
|
||||
* 获取礼物配置
|
||||
@ -667,7 +667,7 @@ public interface PDLiveApi {
|
||||
* @return
|
||||
*/
|
||||
@GET("/api/public/?service=Guide.setWishlistV2")
|
||||
Observable<ResponseModel<String>> setWishlistV2(
|
||||
Observable<ResponseModel<List<String>>> setWishlistV2(
|
||||
@Query("type") int type,
|
||||
@Query("list") String list
|
||||
);
|
||||
|
@ -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<WishListModel> callback) {
|
||||
public void getWishlistV2(int type, HttpCallback<WishListModel> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getWishlistV2()
|
||||
.getWishlistV2(type)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<List<WishListModel>>>() {
|
||||
@ -1339,6 +1336,28 @@ public class LiveNetManager {
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
public void setWishlistV2(int type, String list, HttpCallback<String> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.setWishlistV2(type, list)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<List<String>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<List<String>> stringResponseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(stringResponseModel.getData().getInfo().get(0));
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间取消网络请求
|
||||
*/
|
||||
|
@ -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<Fragment> 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() {
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="15dp" />
|
||||
<solid android:color="#803A37C3" />
|
||||
|
||||
</shape>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="580dp"
|
||||
@ -24,6 +24,19 @@
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/context_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/wish_tab" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/replacement_wish"
|
||||
android:layout_width="117dp"
|
||||
android:layout_height="31dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/background_wish_replacement"
|
||||
android:gravity="center"
|
||||
android:text="@string/replacement_wish_day"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</RelativeLayout>
|
@ -1096,6 +1096,10 @@
|
||||
<string name="aristocrat">貴族</string>
|
||||
<string name="aristocrat_determine">確定</string>
|
||||
<string name="layout_live_anchor_say_ready_title">女神說</string>
|
||||
<string name="replacement_wish_day">重置心願:日</string>
|
||||
<string name="replacement_wish_zhou">重置心願:周</string>
|
||||
<string name="replacement_wish_lunar">重置心願:月</string>
|
||||
<string name="replacement_wish_seasonal">重置心願:季</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user