|
|
@@ -13,15 +13,19 @@ import android.widget.AdapterView;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.di.components.DaggerRechargeQComponent;
|
|
|
import com.sheep.gamegroup.di.modules.RechargeQModule;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.RechargeQEntity;
|
|
|
+import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.presenter.RechargeQContract;
|
|
|
import com.sheep.gamegroup.presenter.RechargeQPresenter;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.MyGridview;
|
|
|
import com.sheep.gamegroup.view.adapter.RechargeQAdapter;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
@@ -29,6 +33,8 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
+import org.xutils.ex.DbException;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -36,6 +42,8 @@ import javax.inject.Inject;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.OnClick;
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* Q币充值
|
|
|
@@ -67,6 +75,8 @@ public class RechargeQAct extends BaseActivity implements RechargeQContract.View
|
|
|
String text_qq;//充值QQ号
|
|
|
String text_QBNumber;//充值金额
|
|
|
|
|
|
+ private UserEntity userEntity;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.rechargeq_layout;
|
|
|
@@ -104,12 +114,51 @@ public class RechargeQAct extends BaseActivity implements RechargeQContract.View
|
|
|
}
|
|
|
adapter.notifyDataSetChanged();
|
|
|
text_QBNumber = rechargeQEntity.getPrice();
|
|
|
- tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),text_QBNumber));
|
|
|
+// tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),text_QBNumber));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
tvZk.setText(getSpannableString());
|
|
|
- tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),"0"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
+ } catch (DbException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(userEntity != null){
|
|
|
+ tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),userEntity.getBalance() +""));
|
|
|
+ }else {
|
|
|
+ SheepApp.get(activity)
|
|
|
+ .getNetComponent()
|
|
|
+ .getApiService()
|
|
|
+ .getInfo()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage.getMsg() +"");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ userEntity = JSON.parseObject(JSONObject.toJSONString(baseMessage.getData()), UserEntity.class);
|
|
|
+ if(userEntity == null){
|
|
|
+ tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),"0"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ MyDbManager.getInstance().saveOrUpdateUser(userEntity);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),userEntity.getBalance() +""));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
etQbNumber.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
@@ -124,11 +173,11 @@ public class RechargeQAct extends BaseActivity implements RechargeQContract.View
|
|
|
if(select != -1 ){
|
|
|
RechargeQEntity rechargeQEntity = adapter.getItem(select);
|
|
|
text_QBNumber = rechargeQEntity.getPrice();
|
|
|
- tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),text_QBNumber));
|
|
|
+// tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),text_QBNumber));
|
|
|
}
|
|
|
}else{
|
|
|
adapter.setInPut(true);
|
|
|
- tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),s.toString()));
|
|
|
+// tvMybNumber.setText(String.format(getString(R.string.rechargeq_amount),s.toString()));
|
|
|
}
|
|
|
}
|
|
|
|