心愿单修改,

This commit is contained in:
18401019693
2023-04-06 14:20:46 +08:00
parent 028f2794bf
commit 3bf6518e25
5 changed files with 223 additions and 43 deletions

View File

@@ -0,0 +1,160 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class WishModel2 extends BaseModel {
@SerializedName("id")
private String id;
@SerializedName("dtime")
private String dtime;
@SerializedName("luid")
private String luid;
@SerializedName("lid")
private String lid;
@SerializedName("wishlist_icon")
private String wishlistIcon;
@SerializedName("wishlist_num")
private String wishlistNum;
@SerializedName("wishlist_progress")
private String wishlistProgress;
@SerializedName("wishlist_name")
private String wishlistName;
@SerializedName("create_time")
private String createTime;
@SerializedName("type")
private int type;
@SerializedName("gift_type")
private int giftType;
@SerializedName("price")
private int price;
public String getId() {
return id;
}
public WishModel2 setId(String id) {
this.id = id;
return this;
}
public String getDtime() {
return dtime;
}
public WishModel2 setDtime(String dtime) {
this.dtime = dtime;
return this;
}
public String getLuid() {
return luid;
}
public WishModel2 setLuid(String luid) {
this.luid = luid;
return this;
}
public String getLid() {
return lid;
}
public WishModel2 setLid(String lid) {
this.lid = lid;
return this;
}
public String getWishlistIcon() {
return wishlistIcon;
}
public WishModel2 setWishlistIcon(String wishlistIcon) {
this.wishlistIcon = wishlistIcon;
return this;
}
public String getWishlistNum() {
return wishlistNum;
}
public WishModel2 setWishlistNum(String wishlistNum) {
this.wishlistNum = wishlistNum;
return this;
}
public String getWishlistProgress() {
return wishlistProgress;
}
public WishModel2 setWishlistProgress(String wishlistProgress) {
this.wishlistProgress = wishlistProgress;
return this;
}
public String getWishlistName() {
return wishlistName;
}
public WishModel2 setWishlistName(String wishlistName) {
this.wishlistName = wishlistName;
return this;
}
public String getCreateTime() {
return createTime;
}
public WishModel2 setCreateTime(String createTime) {
this.createTime = createTime;
return this;
}
public int getType() {
return type;
}
public WishModel2 setType(int type) {
this.type = type;
return this;
}
public int getGiftType() {
return giftType;
}
public WishModel2 setGiftType(int giftType) {
this.giftType = giftType;
return this;
}
public int getPrice() {
return price;
}
public WishModel2 setPrice(int price) {
this.price = price;
return this;
}
public int wishProgress() {
int progress = 0;
try {
progress = Integer.parseInt(wishlistNum);
} catch (NumberFormatException e) {
progress = 0;
}
return progress;
}
public int wishCurrent() {
int current = 0;
try {
current = Integer.parseInt(wishlistProgress);
} catch (NumberFormatException e) {
current = 0;
}
return current;
}
}

View File

@@ -10,12 +10,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.lxj.xpopup.XPopup;
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.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
@@ -24,7 +24,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.LiveNewWishGiftPopup;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@@ -102,17 +101,16 @@ public class LiveNewWishListFragment extends BaseFragment {
public void saveWish() {
List<WishModel> wishList = liveNewWishAdapter.getWishList();
wishList.remove(wishList.size() - 1);
// 1. Gson构造器
GsonBuilder builder = new GsonBuilder();
// 2. 排除使用特定修饰符的字段
builder.excludeFieldsWithoutExposeAnnotation();
// 3. 格式良好的输出
builder.setPrettyPrinting();
// 4. 创建Gson对象
Gson gson = builder.create();
List<WishModel2> wishList2 = new ArrayList<>();
Gson gson = new Gson();
for (WishModel model : wishList) {
WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class);
wishList2.add(model2);
}
LiveNetManager.get(getContext()).
setWishlistV2(type, gson.toJson(wishList), new HttpCallback<String>() {
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
@Override
public void onSuccess(String data) {
ToastUtil.show(data);

View File

@@ -20,6 +20,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.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.event.LiveNewWishListEvent;
import com.yunbao.common.fragment.LiveNewWishListFragment;
@@ -287,17 +288,11 @@ public class LiveNewWishListPopup extends BottomPopupView {
seasonalWish = false;
break;
}
List<WishModel> wishList = new ArrayList<>();
// 1. Gson构造器
GsonBuilder builder = new GsonBuilder();
// 2. 排除使用特定修饰符的字段
builder.excludeFieldsWithoutExposeAnnotation();
// 3. 格式良好的输出
builder.setPrettyPrinting();
// 4. 创建Gson对象
Gson gson = builder.create();
List<WishModel2> wishList2 = new ArrayList<>();
Gson gson = new Gson();
LiveNetManager.get(getContext()).
setWishlistV2(type, gson.toJson(wishList), new HttpCallback<String>() {
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
@Override
public void onSuccess(String data) {
ToastUtil.show(data);