|
|
@@ -6,27 +6,39 @@ import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.Switch;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
|
|
import com.itant.shibei.R;
|
|
|
import com.itant.shibei.base.BaseBeiActivity;
|
|
|
import com.itant.shibei.bean.BeiUser;
|
|
|
+import com.itant.shibei.bean.SystemBean;
|
|
|
import com.itant.shibei.constant.ConstantString;
|
|
|
import com.itant.shibei.manager.UserInfoManager;
|
|
|
import com.itant.shibei.tool.StringTool;
|
|
|
import com.itant.shibei.tool.TimeTool;
|
|
|
+import com.itant.shibei.ui.home.tool.ISystemView;
|
|
|
+import com.itant.shibei.ui.home.tool.SystemPresenter;
|
|
|
import com.itant.shibei.ui.mine.coupon.AddCouponActivity;
|
|
|
import com.itant.shibei.ui.mine.goods.AddGoodsActivity;
|
|
|
+import com.miekir.common.utils.ToastTool;
|
|
|
import com.miekir.common.utils.ViewTool;
|
|
|
+import com.miekir.mvp.presenter.InjectPresenter;
|
|
|
|
|
|
-public class MineActivity extends BaseBeiActivity implements View.OnClickListener {
|
|
|
+public class MineActivity extends BaseBeiActivity implements View.OnClickListener, ISystemView, CompoundButton.OnCheckedChangeListener {
|
|
|
+
|
|
|
+ @InjectPresenter
|
|
|
+ SystemPresenter mSystemPresenter;
|
|
|
|
|
|
// 当前金额
|
|
|
private TextView tv_amount_rest;
|
|
|
// 提现支付宝
|
|
|
private TextView tv_cash_account;
|
|
|
+ private Switch switch_api;
|
|
|
|
|
|
private BeiUser mUser;
|
|
|
|
|
|
@@ -51,12 +63,25 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
ll_admin.setVisibility(View.GONE);
|
|
|
}
|
|
|
|
|
|
+ switch_api = findViewById(R.id.switch_api);
|
|
|
+ switch_api.setOnCheckedChangeListener(this);
|
|
|
+
|
|
|
tv_amount_rest = findViewById(R.id.tv_amount_rest);
|
|
|
tv_cash_account = findViewById(R.id.tv_cash_account);
|
|
|
tv_amount_rest.setText(String.format(ConstantString.MONEY_RMB, StringTool.longCent2Yuan(mUser.currentMoney)));
|
|
|
tv_cash_account.setText("提现支付宝:" + mUser.cashAccount);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+
|
|
|
+ // 这个界面只有我才需要获取API设置
|
|
|
+ if (TextUtils.equals("[email protected]", mUser.email)) {
|
|
|
+ mSystemPresenter.getSystemConfig();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()) {
|
|
|
@@ -107,4 +132,35 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onGetConfigResult(boolean success, String message, SystemBean resultBean) {
|
|
|
+ if (!success || resultBean == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch_api.setOnCheckedChangeListener(null);
|
|
|
+ switch_api.setChecked(resultBean.isVipLimit);
|
|
|
+ switch_api.setOnCheckedChangeListener(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSetApiResult(boolean success, String message, String resultBean) {
|
|
|
+ dismissLoading();
|
|
|
+ if (success) {
|
|
|
+ ToastTool.showShort("设置成功");
|
|
|
+ } else {
|
|
|
+ ToastTool.showShort("设置失败");
|
|
|
+ switch_api.setOnCheckedChangeListener(null);
|
|
|
+ switch_api.setChecked(!switch_api.isChecked());
|
|
|
+ switch_api.setOnCheckedChangeListener(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (buttonView.getId() == switch_api.getId()) {
|
|
|
+ showLoading();
|
|
|
+ mSystemPresenter.setApiConfig(isChecked);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|