|
@@ -9,7 +9,6 @@ import android.view.View;
|
|
|
import android.widget.CompoundButton;
|
|
import android.widget.CompoundButton;
|
|
|
import android.widget.Switch;
|
|
import android.widget.Switch;
|
|
|
|
|
|
|
|
-import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
|
|
|
|
import com.google.android.material.textfield.TextInputEditText;
|
|
import com.google.android.material.textfield.TextInputEditText;
|
|
@@ -37,8 +36,10 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
private Switch switch_api;
|
|
private Switch switch_api;
|
|
|
private Switch switch_walk;
|
|
private Switch switch_walk;
|
|
|
private TextInputEditText et_email;
|
|
private TextInputEditText et_email;
|
|
|
|
|
+ private TextInputEditText et_zfb;
|
|
|
|
|
|
|
|
private BeiUser mUser;
|
|
private BeiUser mUser;
|
|
|
|
|
+ private SystemBean mSystemBean;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int getLayoutID() {
|
|
public int getLayoutID() {
|
|
@@ -55,7 +56,7 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
mUser = UserInfoManager.getInstance().getBeiUser();
|
|
mUser = UserInfoManager.getInstance().getBeiUser();
|
|
|
setTitle(String.format(ConstantString.WELCOME_HELLO, TimeTool.getCurrentTimePeriod()));
|
|
setTitle(String.format(ConstantString.WELCOME_HELLO, TimeTool.getCurrentTimePeriod()));
|
|
|
ViewTool.setOnClickListener(this, this,
|
|
ViewTool.setOnClickListener(this, this,
|
|
|
- new int[]{R.id.tv_my_fav, R.id.btn_exit_login, R.id.tv_add_photo, R.id.btn_set_vip});
|
|
|
|
|
|
|
+ new int[]{R.id.tv_my_fav, R.id.btn_exit_login, R.id.tv_add_photo, R.id.btn_set_vip, R.id.btn_set_zfb});
|
|
|
|
|
|
|
|
// 只有我才能管理后台
|
|
// 只有我才能管理后台
|
|
|
View ll_admin = findViewById(R.id.ll_admin);
|
|
View ll_admin = findViewById(R.id.ll_admin);
|
|
@@ -66,21 +67,25 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
et_email = findViewById(R.id.et_email);
|
|
et_email = findViewById(R.id.et_email);
|
|
|
|
|
+ et_zfb = findViewById(R.id.et_zfb);
|
|
|
switch_api = findViewById(R.id.switch_api);
|
|
switch_api = findViewById(R.id.switch_api);
|
|
|
switch_walk = findViewById(R.id.switch_walk);
|
|
switch_walk = findViewById(R.id.switch_walk);
|
|
|
switch_api.setOnCheckedChangeListener(this);
|
|
switch_api.setOnCheckedChangeListener(this);
|
|
|
switch_walk.setOnCheckedChangeListener(this);
|
|
switch_walk.setOnCheckedChangeListener(this);
|
|
|
- }
|
|
|
|
|
|
|
+ mSystemBean = UserInfoManager.getInstance().getSystemBean();
|
|
|
|
|
+ if (mSystemBean == null) {
|
|
|
|
|
+ ToastTool.showShort("请重启应用");
|
|
|
|
|
+ finish();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
+ switch_api.setOnCheckedChangeListener(null);
|
|
|
|
|
+ switch_api.setChecked(mSystemBean.isVipLimit);
|
|
|
|
|
+ switch_api.setOnCheckedChangeListener(this);
|
|
|
|
|
|
|
|
- // 这个界面只有我才需要获取API设置
|
|
|
|
|
- if (TextUtils.equals(ConstantString.NAME_ADMIN, mUser.email)) {
|
|
|
|
|
- showLoading();
|
|
|
|
|
- mSystemPresenter.getSystemConfig();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ switch_walk.setOnCheckedChangeListener(null);
|
|
|
|
|
+ switch_walk.setChecked(mSystemBean.isWalking);
|
|
|
|
|
+ switch_walk.setOnCheckedChangeListener(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -95,7 +100,7 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
// 设置会员VIP
|
|
// 设置会员VIP
|
|
|
String email = et_email.getEditableText().toString();
|
|
String email = et_email.getEditableText().toString();
|
|
|
if (TextUtils.isEmpty(email)) {
|
|
if (TextUtils.isEmpty(email)) {
|
|
|
- ToastTool.showShort("账号不能为空");
|
|
|
|
|
|
|
+ ToastTool.showShort("要升级的账号不能为空");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -103,6 +108,17 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
mSystemPresenter.setVip(email);
|
|
mSystemPresenter.setVip(email);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case R.id.btn_set_zfb:
|
|
|
|
|
+ String zfb = et_zfb.getEditableText().toString();
|
|
|
|
|
+ if (TextUtils.isEmpty(zfb)) {
|
|
|
|
|
+ ToastTool.showShort("支付宝账号不能为空");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ showLoading();
|
|
|
|
|
+ mSystemPresenter.setConfig(SystemPresenter.CONFIG_TYPE_ZFB, false, zfb);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
case R.id.tv_add_photo:
|
|
case R.id.tv_add_photo:
|
|
|
startActivity(new Intent(this, AddPhotoActivity.class));
|
|
startActivity(new Intent(this, AddPhotoActivity.class));
|
|
|
break;
|
|
break;
|
|
@@ -120,57 +136,61 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
*/
|
|
*/
|
|
|
private void sureToExit() {
|
|
private void sureToExit() {
|
|
|
AlertDialog alertDialog = new AlertDialog.Builder(this)
|
|
AlertDialog alertDialog = new AlertDialog.Builder(this)
|
|
|
- .setMessage("确定退出当前账号?")
|
|
|
|
|
- .setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
|
|
|
|
|
- .setPositiveButton("确定", (DialogInterface dialog, int which) -> {
|
|
|
|
|
- dialog.dismiss();
|
|
|
|
|
- UserInfoManager.getInstance().setBeiUser(null);
|
|
|
|
|
- setResult(RESULT_OK);
|
|
|
|
|
- finish();
|
|
|
|
|
- }).create();
|
|
|
|
|
|
|
+ .setMessage("确定退出当前账号?")
|
|
|
|
|
+ .setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
|
|
|
|
|
+ .setPositiveButton("确定", (DialogInterface dialog, int which) -> {
|
|
|
|
|
+ dialog.dismiss();
|
|
|
|
|
+ UserInfoManager.getInstance().setBeiUser(null);
|
|
|
|
|
+ setResult(RESULT_OK);
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }).create();
|
|
|
alertDialog.show();
|
|
alertDialog.show();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onGetConfigResult(boolean success, String message, SystemBean resultBean) {
|
|
public void onGetConfigResult(boolean success, String message, SystemBean resultBean) {
|
|
|
- dismissLoading();
|
|
|
|
|
- if (!success || resultBean == null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- switch_api.setOnCheckedChangeListener(null);
|
|
|
|
|
- switch_api.setChecked(resultBean.isVipLimit);
|
|
|
|
|
- switch_api.setOnCheckedChangeListener(this);
|
|
|
|
|
-
|
|
|
|
|
- switch_walk.setOnCheckedChangeListener(null);
|
|
|
|
|
- switch_walk.setChecked(resultBean.isWalking);
|
|
|
|
|
- switch_walk.setOnCheckedChangeListener(this);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onSetDoorResult(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
|
|
@Override
|
|
|
- public void onSetWalkResult(boolean success, String message, String resultBean) {
|
|
|
|
|
|
|
+ public void onSetConfigResult(int configType, boolean success, String message, String newZFB) {
|
|
|
dismissLoading();
|
|
dismissLoading();
|
|
|
- if (success) {
|
|
|
|
|
- ToastTool.showShort("设置成功");
|
|
|
|
|
- } else {
|
|
|
|
|
- ToastTool.showShort("设置失败");
|
|
|
|
|
- switch_walk.setOnCheckedChangeListener(null);
|
|
|
|
|
- switch_walk.setChecked(!switch_walk.isChecked());
|
|
|
|
|
- switch_walk.setOnCheckedChangeListener(this);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ switch (configType) {
|
|
|
|
|
+ case SystemPresenter.CONFIG_TYPE_DOOR:
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ ToastTool.showShort("设置成功");
|
|
|
|
|
+ mSystemBean.isVipLimit = !mSystemBean.isVipLimit;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("设置失败");
|
|
|
|
|
+ switch_api.setOnCheckedChangeListener(null);
|
|
|
|
|
+ switch_api.setChecked(!switch_api.isChecked());
|
|
|
|
|
+ switch_api.setOnCheckedChangeListener(this);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case SystemPresenter.CONFIG_TYPE_WALK:
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ ToastTool.showShort("设置成功");
|
|
|
|
|
+ mSystemBean.isWalking = !mSystemBean.isWalking;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("设置失败");
|
|
|
|
|
+ switch_walk.setOnCheckedChangeListener(null);
|
|
|
|
|
+ switch_walk.setChecked(!switch_walk.isChecked());
|
|
|
|
|
+ switch_walk.setOnCheckedChangeListener(this);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case SystemPresenter.CONFIG_TYPE_ZFB:
|
|
|
|
|
+ default:
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ mSystemBean.zfb = newZFB;
|
|
|
|
|
+ ToastTool.showShort("设置成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("设置成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -184,9 +204,9 @@ public class MineActivity extends BaseBeiActivity implements View.OnClickListene
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
showLoading();
|
|
showLoading();
|
|
|
if (buttonView.getId() == switch_api.getId()) {
|
|
if (buttonView.getId() == switch_api.getId()) {
|
|
|
- mSystemPresenter.setDoor(isChecked);
|
|
|
|
|
|
|
+ mSystemPresenter.setConfig(SystemPresenter.CONFIG_TYPE_DOOR, isChecked, mSystemBean.zfb);
|
|
|
} else if (buttonView.getId() == switch_walk.getId()) {
|
|
} else if (buttonView.getId() == switch_walk.getId()) {
|
|
|
- mSystemPresenter.setWalk(isChecked);
|
|
|
|
|
|
|
+ mSystemPresenter.setConfig(SystemPresenter.CONFIG_TYPE_WALK, isChecked, mSystemBean.zfb);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|