|
|
@@ -3,7 +3,9 @@ package com.sheep.gamegroup.view.dialog;
|
|
|
import android.app.Activity;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
+import android.text.Editable;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
@@ -14,6 +16,7 @@ import android.widget.TextView;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
+import com.sheep.gamegroup.model.entity.GamePayList;
|
|
|
import com.sheep.gamegroup.model.entity.GridViewEntity;
|
|
|
import com.sheep.gamegroup.model.entity.PayEntity;
|
|
|
import com.sheep.gamegroup.model.entity.RechargeEntity;
|
|
|
@@ -38,6 +41,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
+import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
@@ -47,7 +51,6 @@ import rx.schedulers.Schedulers;
|
|
|
public class DialogPayGame {
|
|
|
private Activity activity;
|
|
|
private String game_account_etStr;
|
|
|
- private String game_pay_etStr;
|
|
|
private int gao;
|
|
|
private int maxShowCount;
|
|
|
private RefreshLayout swipe_container;
|
|
|
@@ -75,10 +78,11 @@ public class DialogPayGame {
|
|
|
private int select;
|
|
|
private String amount;
|
|
|
|
|
|
+ private GamePayList gameVoucherAndRatio;
|
|
|
+
|
|
|
public DialogPayGame(Activity activity, PayEntity payEntity) {
|
|
|
this.activity = activity;
|
|
|
this.game_account_etStr = game_account_etStr;
|
|
|
- this.game_pay_etStr = game_pay_etStr;
|
|
|
this.gameId = gameId;
|
|
|
this.payEntity = payEntity;
|
|
|
gao = SheepApp.getInstance().getResources().getDimensionPixelSize(R.dimen.content_padding_10)*5;
|
|
|
@@ -103,7 +107,7 @@ public class DialogPayGame {
|
|
|
TextView sureTv = view.findViewById(R.id.pay_sure_tv);
|
|
|
//你需要支付1110元
|
|
|
TextView pay_game_show_price_tv = view.findViewById(R.id.pay_game_show_price_tv);
|
|
|
- pay_game_show_price_tv.setText("你需要支付"+ game_pay_etStr +"元");
|
|
|
+ pay_game_show_price_tv.setText("你需要支付"+ 0 +"元");
|
|
|
money_et = view.findViewById(R.id.money_et);
|
|
|
pay_listview = view.findViewById(R.id.pay_listview);
|
|
|
adpPayGameDialog = new AdpPayGameDialog(list ,activity);
|
|
|
@@ -143,7 +147,9 @@ public class DialogPayGame {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- initData();
|
|
|
+ gameId = payEntity.getGame_id();
|
|
|
+// initData();
|
|
|
+ getVoucherAndRatio();
|
|
|
}
|
|
|
|
|
|
public void initData(){
|
|
|
@@ -151,7 +157,7 @@ public class DialogPayGame {
|
|
|
ViewUtil.newInstance()
|
|
|
.showProgress(activity, false);
|
|
|
gameId = payEntity.getGame_id();
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().can_user_sheep_amount(Integer.valueOf(game_pay_etStr), gameId)
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().can_user_sheep_amount(Integer.valueOf(0), gameId)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@@ -179,6 +185,22 @@ public class DialogPayGame {
|
|
|
});
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**\
|
|
|
+ * if(Double.valueOf(balance) > 0){
|
|
|
+ ;
|
|
|
+ if(Float.valueOf(game_pay_etStr) > Float.valueOf(balance)){
|
|
|
+ balanceStr = balance;
|
|
|
+ }else {
|
|
|
+ balanceStr = game_pay_etStr;
|
|
|
+ }
|
|
|
+ RechargeEntity rechargeEntity = new RechargeEntity();
|
|
|
+ rechargeEntity.setSelect(true);
|
|
|
+ rechargeEntity.setId(3);
|
|
|
+ rechargeEntity.setName("绵羊币 (可用"+ 0 +") 指非定向货币+定向货币");
|
|
|
+ list.add(rechargeEntity);
|
|
|
+ }
|
|
|
+ */
|
|
|
private void getNetComponent(){
|
|
|
ViewUtil.newInstance()
|
|
|
.showProgress(activity, false);
|
|
|
@@ -194,20 +216,11 @@ public class DialogPayGame {
|
|
|
List<RechargeEntity> lists = baseMessage.getDatas(RechargeEntity.class);
|
|
|
list.clear();
|
|
|
try{
|
|
|
- String balanceStr;
|
|
|
- if(Double.valueOf(balance) > 0){
|
|
|
- ;
|
|
|
- if(Float.valueOf(game_pay_etStr) > Float.valueOf(balance)){
|
|
|
- balanceStr = balance;
|
|
|
- }else {
|
|
|
- balanceStr = game_pay_etStr;
|
|
|
- }
|
|
|
- RechargeEntity rechargeEntity = new RechargeEntity();
|
|
|
- rechargeEntity.setSelect(true);
|
|
|
- rechargeEntity.setId(3);
|
|
|
- rechargeEntity.setName("绵羊币 (可用"+ balanceStr +") 指非定向货币+定向货币");
|
|
|
- list.add(rechargeEntity);
|
|
|
- }
|
|
|
+ RechargeEntity rechargeEntity = new RechargeEntity();
|
|
|
+ rechargeEntity.setSelect(true);
|
|
|
+ rechargeEntity.setId(3);
|
|
|
+ rechargeEntity.setName("绵羊币 (可用"+ 0 +") 指非定向货币+定向货币");
|
|
|
+ list.add(rechargeEntity);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -292,7 +305,7 @@ public class DialogPayGame {
|
|
|
.showProgress(activity, false);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("account", payEntity.getAccount());
|
|
|
- jsonObject.put("amount", Float.valueOf(game_pay_etStr));
|
|
|
+ jsonObject.put("amount", Float.valueOf(0));//todo
|
|
|
jsonObject.put("game_id", payEntity.getGame_id()+"");
|
|
|
jsonObject.put("pay_type", pay_type);
|
|
|
jsonObject.put("use_voucher", use_voucher);
|
|
|
@@ -391,5 +404,51 @@ public class DialogPayGame {
|
|
|
if(!TextUtils.isEmpty(money_et.getText()) && !TextUtils.isEmpty(money_et.getText().toString().trim())){
|
|
|
amount = money_et.getText().toString().trim();
|
|
|
}
|
|
|
+
|
|
|
+ money_et.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+ if (!TextUtils.isEmpty(s) && s.length() > 0) {
|
|
|
+ makePriceShow(s.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取可用金额和比率
|
|
|
+ */
|
|
|
+ private void getVoucherAndRatio(){
|
|
|
+
|
|
|
+ CommonUtil.getInstance()
|
|
|
+ .getVoucherAndRatio(activity, gameId, new Action1<BaseMessage>() {
|
|
|
+ @Override
|
|
|
+ public void call(BaseMessage baseMessage) {
|
|
|
+ if(baseMessage != null){
|
|
|
+ gameVoucherAndRatio = baseMessage.getData(GamePayList.class);
|
|
|
+ }
|
|
|
+ getNetComponent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算金额显示
|
|
|
+ */
|
|
|
+ private void makePriceShow(String price){
|
|
|
+ String p = "绵羊币 (可用"+ 0 +") 指非定向货币+定向货币";
|
|
|
+ TextView textView = pay_listview.getChildAt(0).findViewById(R.id.pay_game_dialog_item_tv);
|
|
|
+ textView.setText(p);
|
|
|
}
|
|
|
}
|