コード例 #1
0
 @Override
 public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
   if (isParameterValid()) {
     ApiHelper apiHelper = ApiHelper.getInstance(this);
     getSupportLoaderManager()
         .restartLoader(
             WTApplication.NETWORK_LOADER_DEFAULT,
             apiHelper.userUpdatePassword(
                 edtOld.getText().toString(), edtConfirm.getText().toString()),
             this);
   }
 }
コード例 #2
0
 @Override
 public void onLoadFinished(Loader<HttpRequestResult> arg0, HttpRequestResult result) {
   if (result.getResponseCode() == 0) {
     try {
       WTApplication application = WTApplication.getInstance();
       JSONObject json = new JSONObject(result.getStrResponseCon());
       application.session = json.getString("Session");
       AccountManager am = AccountManager.get(this);
       Account[] ac = am.getAccountsByType(WTApplication.ACCOUNT_TYPE);
       am.setAuthToken(ac[0], WTApplication.AUTHTOKEN_TYPE, application.session);
       Toast.makeText(
               this,
               getResources().getString(R.string.update_password_success),
               Toast.LENGTH_SHORT)
           .show();
       btnConfirm.setChecked(false);
       ApiHelper.getInstance(this).setSession(application.session);
       finish();
     } catch (JSONException e) {
       e.printStackTrace();
     }
   } else {
     ExceptionToast.show(this, result.getResponseCode());
   }
 }