优化支付方式
This commit is contained in:
@@ -44,7 +44,7 @@ public class ChargePresenter extends PayPresenter<IChargeView> {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(chargeBeans -> {
|
||||
if (chargeBeans != null) {
|
||||
getMvpView().buildChargeList(chargeBeans);
|
||||
getMvpView().buildChargeList(chargeBeans.getList());
|
||||
} else {
|
||||
getMvpView().getChargeListFail("请求数据为空");
|
||||
}
|
||||
|
@@ -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<ChargeBean> mBigList;
|
||||
List<ChargeBean> 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<ChargeBean> 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<ChargeBean> 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<List<ChargeBean>>() {
|
||||
PayModel.get().getChargeList(1).subscribe(new BeanObserver<ChargeListResult>() {
|
||||
@Override
|
||||
public void onSuccess(List<ChargeBean> chargeBeans) {
|
||||
onGetChargeList(chargeBeans);
|
||||
public void onSuccess(ChargeListResult chargeBeans) {
|
||||
mBigList = chargeBeans.getBigList();
|
||||
mList = chargeBeans.getList();
|
||||
mListSize = chargeBeans.getList().size();
|
||||
onGetChargeList(chargeBeans.getList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -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<List<ChargeBean>> {
|
||||
|
||||
@Data
|
||||
public class ChargeListResult {
|
||||
List<ChargeBean> list;
|
||||
List<ChargeBean> bigList;
|
||||
}
|
||||
|
@@ -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<List<ChargeBean>> getChargeList(int channelType);
|
||||
Single<ChargeListResult> getChargeList(int channelType);
|
||||
|
||||
//发起充值u
|
||||
Single<JsonObject> requestCharge(Context context, String chargeProdId, String payChannel);
|
||||
|
@@ -175,7 +175,7 @@ public class PayModel extends BaseModel implements IPayModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<ChargeBean>> getChargeList(int channelType) {
|
||||
public Single<ChargeListResult> 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<ChargeListResult> getChargeList(@Query("channelType") String channelType);
|
||||
@GET("/chargeprod/listV2")
|
||||
Single<ServiceResult<ChargeListResult>> getChargeList(@Query("channelType") String channelType);
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user