Esempio n. 1
0
  private void bindEamil() {
    code = code_editText.getText().toString();
    if (TextUtils.isEmpty(code) || TextUtils.isEmpty(pa)) {
      showWarning("验证码错误");
    }
    BaseParams baseParams = new BaseParams("user/chgemail");
    baseParams.addParams("token", MyAccount.getInstance().getToken());
    baseParams.addParams("email", email);
    baseParams.addParams("code", code);
    baseParams.addParams("pa", pa);
    baseParams.addSign();
    x.http()
        .post(
            baseParams.getRequestParams(),
            new Callback.CommonCallback<String>() {
              @Override
              public void onSuccess(String result) {
                MyLog.i("bindEmail===" + result);
                try {
                  JSONObject js = new JSONObject(result);
                  boolean su = js.getBoolean("success");
                  int code = js.getInt("code");
                  if (su && code == 200) {
                    CusToast.showToast(getActivity(), "邮箱绑定成功", Toast.LENGTH_SHORT);
                    userInfo.setEmail(email);
                    MyAcountSettingFragment myAcountSettingFragment = new MyAcountSettingFragment();
                    Bundle bundle = new Bundle();
                    bundle.putString("tag", "init");
                    myAcountSettingFragment.setArguments(bundle);
                    FragmentTransaction transaction =
                        getActivity().getSupportFragmentManager().beginTransaction();
                    transaction.setCustomAnimations(R.anim.in_form_left, R.anim.out_to_right);
                    transaction
                        .replace(R.id.contianner_mysetting, myAcountSettingFragment)
                        .commit();
                  } else {
                    String mes = js.getString("msg");
                  }

                } catch (JSONException e) {
                  e.printStackTrace();
                }
              }

              @Override
              public void onError(Throwable ex, boolean isOnCallback) {}

              @Override
              public void onCancelled(CancelledException cex) {}

              @Override
              public void onFinished() {}
            });
  }
Esempio n. 2
0
 @Override
 public void onCreate(@Nullable Bundle savedInstanceState) {
   userInfo = MyAccount.getInstance().getUserInfo();
   super.onCreate(savedInstanceState);
 }