|
|
@@ -4,11 +4,13 @@ import android.app.Activity;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.Html;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.GridView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.kfzs.duanduan.event.BigEvent;
|
|
|
import com.kfzs.duanduan.event.EventTypes;
|
|
|
@@ -17,6 +19,7 @@ import com.sheep.gamegroup.di.modules.WithdrawalModule;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.GridViewEntity;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.presenter.WithdrawalContract;
|
|
|
import com.sheep.gamegroup.presenter.WithdrawalPresenter;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
@@ -30,6 +33,7 @@ import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.xutils.ex.DbException;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -40,6 +44,9 @@ import javax.inject.Inject;
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.OnClick;
|
|
|
+import rx.Scheduler;
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* 提现
|
|
|
@@ -69,6 +76,8 @@ public class WithdrawalAct extends BaseActivity implements WithdrawalContract.Vi
|
|
|
private String balanceAmount = "0";//余额
|
|
|
|
|
|
private boolean isFinishFirstWithdrawal;//是否完成首次提现任务
|
|
|
+
|
|
|
+ private UserEntity userEntity;
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.withdrawal_layout;
|
|
|
@@ -77,6 +86,7 @@ public class WithdrawalAct extends BaseActivity implements WithdrawalContract.Vi
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
activity = this;
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
isFinishFirstWithdrawal = getIntent().getBooleanExtra(Boolean.class.getSimpleName(), true);
|
|
|
TitleBarUtils
|
|
|
.getInstance()
|
|
|
@@ -122,7 +132,7 @@ public class WithdrawalAct extends BaseActivity implements WithdrawalContract.Vi
|
|
|
public void initData() {
|
|
|
|
|
|
try {
|
|
|
- UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
+ userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
if(userEntity != null){
|
|
|
weixin_name_tv.setText(userEntity.getWx_nickname() +"");
|
|
|
}
|
|
|
@@ -238,4 +248,52 @@ public class WithdrawalAct extends BaseActivity implements WithdrawalContract.Vi
|
|
|
String sr = "可提现金额 <font color='#ff2d4b'><big>" + balanceAmount + "</big></font> 元";
|
|
|
withdrawal_click_bindname_tv.setText(Html.fromHtml(sr));
|
|
|
}
|
|
|
+
|
|
|
+ @Subscribe
|
|
|
+ public void onEventMainThread(BigEvent event){
|
|
|
+ switch (event.getEventTypes()){
|
|
|
+ case REFRESH_DATA_PHONE:
|
|
|
+ refreshData();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
+ }
|
|
|
+ //Todo 刷新用户信息,可以写一个公用的
|
|
|
+ /**
|
|
|
+ * 刷新用户信息
|
|
|
+ */
|
|
|
+ private void refreshData(){
|
|
|
+ showProgress(false);
|
|
|
+ SheepApp.get(this)
|
|
|
+ .getNetComponent()
|
|
|
+ .getApiService()
|
|
|
+ .getInfo()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(this) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ hideProgress();
|
|
|
+ G.showToast(""+baseMessage.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ hideProgress();
|
|
|
+ userEntity = JSON.parseObject(JSONObject.toJSONString(baseMessage.getData()), UserEntity.class);
|
|
|
+ try {
|
|
|
+ MyDbManager.getInstance().saveOrUpdateUser(userEntity);
|
|
|
+ initData();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|