diff --git a/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java b/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java index 48237ec96..3318c3856 100644 --- a/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java +++ b/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java @@ -44,7 +44,7 @@ public class ChargePresenter extends PayPresenter { .observeOn(AndroidSchedulers.mainThread()) .subscribe(chargeBeans -> { if (chargeBeans != null) { - getMvpView().buildChargeList(chargeBeans); + getMvpView().buildChargeList(chargeBeans.getList()); } else { getMvpView().getChargeListFail("请求数据为空"); } diff --git a/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java b/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java index 5fae2a9ce..9fd2fe8a6 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java +++ b/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java @@ -27,6 +27,7 @@ import com.yizhuan.xchat_android_core.Constants; import com.yizhuan.xchat_android_core.UriProvider; import com.yizhuan.xchat_android_core.auth.AuthModel; import com.yizhuan.xchat_android_core.bean.response.ServiceResult; +import com.yizhuan.xchat_android_core.bean.response.result.ChargeListResult; import com.yizhuan.xchat_android_core.pay.PayModel; import com.yizhuan.xchat_android_core.pay.PaymentActivity; import com.yizhuan.xchat_android_core.pay.bean.ChargeBean; @@ -83,6 +84,9 @@ public class ChargeActivity extends BaseActivity { private LinearLayout ll_more; private ChargeBean mSelectChargeBean; + List mBigList; + List mList; + private int mListSize; private volatile String payChannel = Constants.CHARGE_WX; @@ -162,6 +166,26 @@ public class ChargeActivity extends BaseActivity { this.payChannel = payChannel; boolean selectWeChatPay = (Objects.equals(this.payChannel, Constants.CHARGE_WX)); boolean selectAliPay = (Objects.equals(this.payChannel, Constants.CHARGE_ALIPAY)); + if (selectAliPay){ + if (mList.size() != mListSize)return; + for(ChargeBean bigList:mBigList) { + mList.add(bigList); + } + mChargeAdapter.setNewData(mList); + mChargeAdapter.notifyDataSetChanged(); + } else { + if (mList.size() > mListSize){ + if (ListUtils.isListEmpty(mBigList))return; + if (mSelectChargeBean.equals(mBigList.get(0))) + setItemSelect(0); + for(ChargeBean bigList:mBigList) { + mList.remove(bigList); + } + mChargeAdapter.setNewData(mList); + mChargeAdapter.notifyDataSetChanged(); + + } + } switch (defaultPay){ case ALI_PAY_CLOSE: iv_sel_first.setSelected(selectAliPay); @@ -227,20 +251,7 @@ public class ChargeActivity extends BaseActivity { mChargeAdapter = new ChargeAdapter(); mRecyclerView.setAdapter(mChargeAdapter); mChargeAdapter.setOnItemClickListener((baseQuickAdapter, view, position) -> { - List list = mChargeAdapter.getData(); - if (ListUtils.isListEmpty(list)) return; - - // 空对象,不让蒙板遮挡最后一个item; - ChargeBean temp = list.get(position); - if (TextUtils.isEmpty(temp.getProdName())) - return; - - mSelectChargeBean = list.get(position); - int size = list.size(); - for (int i = 0; i < size; i++) { - list.get(i).isSelected = position == i; - } - mChargeAdapter.notifyDataSetChanged(); + setItemSelect(position); // int money = mSelectChargeBean.getMoney(); // if (money >= 30000) { // // 大于 3w 的时候,隐藏微信支付的选项 @@ -255,6 +266,23 @@ public class ChargeActivity extends BaseActivity { onRefreshing(); } + private void setItemSelect(int position){ + List list = mChargeAdapter.getData(); + if (ListUtils.isListEmpty(list)) return; + + // 空对象,不让蒙板遮挡最后一个item; + ChargeBean temp = list.get(position); + if (TextUtils.isEmpty(temp.getProdName())) + return; + + mSelectChargeBean = list.get(position); + int size = list.size(); + for (int i = 0; i < size; i++) { + list.get(i).isSelected = position == i; + } + mChargeAdapter.notifyDataSetChanged(); + } + public void onLoadingData() { UserInfo userInfos = UserModel.get().getCacheLoginUserInfo(); if (userInfos != null) { @@ -278,10 +306,13 @@ public class ChargeActivity extends BaseActivity { } public void onRefreshing() { - PayModel.get().getChargeList(1).subscribe(new BeanObserver>() { + PayModel.get().getChargeList(1).subscribe(new BeanObserver() { @Override - public void onSuccess(List chargeBeans) { - onGetChargeList(chargeBeans); + public void onSuccess(ChargeListResult chargeBeans) { + mBigList = chargeBeans.getBigList(); + mList = chargeBeans.getList(); + mListSize = chargeBeans.getList().size(); + onGetChargeList(chargeBeans.getList()); } @Override diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/bean/response/result/ChargeListResult.java b/core/src/main/java/com/yizhuan/xchat_android_core/bean/response/result/ChargeListResult.java index 22a5aa8dc..21ec94953 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/bean/response/result/ChargeListResult.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/bean/response/result/ChargeListResult.java @@ -5,10 +5,13 @@ import com.yizhuan.xchat_android_core.bean.response.ServiceResult; import java.util.List; +import lombok.Data; + /** * Created by zhouxiangfeng on 2017/5/4. */ - -public class ChargeListResult extends ServiceResult> { - +@Data +public class ChargeListResult { + List list; + List bigList; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java index c80f35fce..c1c2c37c9 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java @@ -5,6 +5,7 @@ import android.content.Context; import com.google.gson.JsonObject; import com.yizhuan.xchat_android_core.base.IModel; import com.yizhuan.xchat_android_core.bean.response.ServiceResult; +import com.yizhuan.xchat_android_core.bean.response.result.ChargeListResult; import com.yizhuan.xchat_android_core.pay.bean.ChargeBean; import com.yizhuan.xchat_android_core.pay.bean.WalletInfo; import com.yizhuan.xchat_android_core.pay.bean.WxPayType; @@ -37,7 +38,7 @@ public interface IPayModel extends IModel { 3,苹果充值 */ - Single> getChargeList(int channelType); + Single getChargeList(int channelType); //发起充值u Single requestCharge(Context context, String chargeProdId, String payChannel); diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java index af24bd4ca..c662d905a 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java @@ -175,7 +175,7 @@ public class PayModel extends BaseModel implements IPayModel { } @Override - public Single> getChargeList(int channelType) { + public Single getChargeList(int channelType) { return api.getChargeList( String.valueOf(channelType) ) @@ -451,8 +451,8 @@ public class PayModel extends BaseModel implements IPayModel { * @param channelType * @return */ - @GET("/chargeprod/list") - Single getChargeList(@Query("channelType") String channelType); + @GET("/chargeprod/listV2") + Single> getChargeList(@Query("channelType") String channelType); /**