@Override
 protected void onResume() {
   // TODO Auto-generated method stub
   super.onResume();
   if (processDialog != null && processDialog.isShowing()) {
     processDialog.dismiss();
   }
 }
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (processDialog != null && processDialog.isShowing()) {
      processDialog.dismiss();
    }
    // 拍照回调
    if (requestCode == Constants.REQUEST_CODE_TAKE_PHOTO
        || requestCode == Constants.REQUEST_CODE_GALLERY) {
      if (resultCode == RESULT_OK) {
        Uri photoUri = null;
        if (data == null) {
          photoUri = Uri.fromFile(getTempFile(this, null));
        } else {
          photoUri = data.getData();
        }
        Log.i(TAG, "crop photo data :" + photoUri);
        cropPhoto(photoUri);
      }

    } else if (requestCode == Constants.ACTION_IMAGE_CROP) {

      if (resultCode == RESULT_OK) {

        // 拿到剪切数据
        modifiedUserPhoto = data.getParcelableExtra("data");

        // 图像保存到文件中
        FileOutputStream foutput = null;
        try {
          File temp = getTempFile(this, "crop_temp.jpg");
          foutput = new FileOutputStream(temp);
          modifiedUserPhoto.compress(Bitmap.CompressFormat.JPEG, 100, foutput);
          //                    processDialog.show("请稍后...");
          modifyUserPhoto(temp.getPath());
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        } finally {
          if (null != foutput) {
            try {
              foutput.close();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        }
      }
    } else {
      // 第三方验证回调
      authHelper.setActivityResult(requestCode, resultCode, data);
    }
  }
  @AfterViews
  void bindViews() {
    userService = RemoteServiceManager.getRemoteService(IRpcJobUservice.class);
    //        options = new DisplayImageOptions.Builder().cacheInMemory(true)
    //                .bitmapConfig(Bitmap.Config.RGB_565).cacheOnDisk(true)
    //                .considerExifParams(true).build();

    SystemServicesUtils.displayCustomTitle(getApplicationContext(), getSupportActionBar(), "账号管理");

    processDialog = new ProcessDialog(this);
    unBindDialog = new GenericDialog(this, R.layout.unbind_account_dialog);
    unBindDialog.setCancelable(true);

    authHelper =
        new ThirdPartAuthHelper(
            this,
            new AuthResultCallback() {

              @Override
              public void onAuthResult(String openId, String authType) {
                if (isModifyUserPhoto) { // 为了拿到第三方头像而验证
                  // modifyUserPhoto_BindValue = openId;

                } else { // 为了绑定第三方账号而验证

                  bindOpenId = openId;
                  // 绑定qq账号
                  if (Constants.LOGIN_TYPE_QQ.equals(authType)) {
                    bindQQAccount(openId);
                  }

                  // 绑定weibo账号
                  if (Constants.LOGIN_TYPE_WEIBO.equals(authType)) {
                    bindWeiboAccount(openId);
                  }
                  // getUserPhotoInThird(authType, openId);
                }
              }
            });

    // 显示头像
    if (userPhotoUrl != null) {
      editHeadBtn.setVisibility(View.VISIBLE);
      Picasso.with(this).load(userPhotoUrl).into(userPhotoImg);

    } else {
      editHeadBtn.setVisibility(View.GONE);
    }

    // 账号信息
    if (!gotoModifyPhoto) {
      processDialog.show();
    }
    findAccountsInfo();

    if (gotoModifyPhoto) {
      findUserHeadPhoto();
    }
  }
 /** 绑定微博 */
 @Click(R.id.weiboRowRl)
 void onBindWeiboAccount() {
   if (weiboOpenId != null) {
     unBindDialog.show();
     unbindType = BUND_TYPE_WEIBO;
   } else {
     processDialog.show();
     authHelper.requestSinaWeiboAuth();
   }
 }
 /** 绑定微信 */
 @Click(R.id.wechatRowRl)
 void onBindWechatAccount() {
   if (wechatOpenId != null) {
     unBindDialog.show();
     unbindType = BUND_TYPE_WECHAT;
   } else {
     processDialog.show();
     authHelper.requestWechatAuth(this);
   }
 }
 /** 绑定qq */
 @Click(R.id.qqRowRl)
 void onBindQQAccount() {
   if (qqOpenId != null) {
     unBindDialog.show();
     unbindType = BUND_TYPE_QQ;
   } else {
     processDialog.show();
     authHelper.requestTencentQQAuth();
   }
 }
  /** 对话框按钮单击事件 */
  public void onButtonClick(View view) {
    Log.i(TAG, "buttonClick");
    switch (view.getId()) {
      case R.id.capturePhotoLL:
        modifyUserPhotoDialog.dismiss();
        takePhoto();
        break;

      case R.id.galleryPhotoLL:
        modifyUserPhotoDialog.dismiss();
        openGallery();
        break;
      case R.id.unBindBtn:
        unBindDialog.dismiss();

        boolean shouldUnbind = false;
        if (mobile != null) {
          shouldUnbind = true;
        } else {
          if (qqOpenId != null && weiboOpenId != null && wechatOpenId != null) {
            shouldUnbind = true;
          }
        }
        if (shouldUnbind) {
          processDialog.show();
          if (BUND_TYPE_QQ.equals(unbindType)) {
            unbindQQAccount();
          }
          if (BUND_TYPE_WEIBO.equals(unbindType)) {
            unbindWeiBoAccount();
          }
          if (BUND_TYPE_WECHAT.equals(unbindType)) {
            unbindWechatAccount();
          }
        } else {
          Toast.makeText(this, "解除绑定失败,请先绑定手机号码并设置密码", Toast.LENGTH_SHORT).show();
        }
        break;
      case R.id.cancelUnbindBtn:
        unBindDialog.dismiss();
        break;
      case R.id.qqPhotoLL:
        onModifyUserPhotoInQQ();
        break;
      case R.id.weiboPhotoLL:
        onModifyUserPhotoInWeibo();
        break;
    }
    // modifyUserPhotoDialog.dismiss();
  }
  /** 获取第三方的头像 */
  private void getUserPhotoInThird(String login_type, final String bindValue) {
    if (authHelper.isSessionValid(login_type)) {
      processDialog.show();
      if (Constants.LOGIN_TYPE_QQ.equals(login_type)) {
        authHelper.getUserInfoInQQ(
            new IUiListener() {

              @Override
              public void onError(UiError arg0) {
                if (processDialog != null && processDialog.isShowing()) {
                  processDialog.dismiss();
                }
              }

              @Override
              public void onComplete(Object response) {
                JSONObject json = (JSONObject) response;
                Log.i(TAG, response + "");
                if (json.has("figureurl_qq_2")) {
                  try {
                    // 获取第三方账户头像
                    String url = json.getString("figureurl_qq_2");

                    // 同时用获取的头像,创建账号
                    Log.i(TAG, url);
                    bindThirdPhoto(BUND_TYPE_QQ, bindValue, url);

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

              @Override
              public void onCancel() {
                if (processDialog != null && processDialog.isShowing()) {
                  processDialog.dismiss();
                }
              }
            });
      }
      if (BUND_TYPE_WECHAT.equals(login_type)) {
        // 同时用获取的头像,创建账号
        bindThirdPhoto(
            BUND_TYPE_WECHAT,
            bindValue,
            SharedPreferencesUtil.getValue(this, Constants.HEAD_IMG_URL, ""));
      }
      if (Constants.LOGIN_TYPE_WEIBO.equals(login_type)) {
        authHelper.getUserInfoInWeibo(
            new com.sina.weibo.sdk.net.RequestListener() {

              @Override
              public void onWeiboException(WeiboException exc) {
                Log.e(TAG, exc.getMessage());
                if (processDialog != null && processDialog.isShowing()) {
                  processDialog.dismiss();
                }
              }

              @Override
              public void onComplete(String response) {
                if (!TextUtils.isEmpty(response)) {
                  User user = User.parse(response);
                  Log.i(TAG, "微博头像 :" + user.profile_image_url);
                  bindThirdPhoto("weiBo", bindValue, user.profile_image_url);
                  // 同时用获取的头像,创建账号

                }
              }
            });
      }
    }
  }
 /** 修改wechat头像 */
 void onModifyUserPhotoInWechat() {
   modifyUserPhotoDialog.dismiss();
   processDialog.show();
   modifyUserPhotoInThird(wechat_photo_url);
 }
 /** 修改qq头像 */
 void onModifyUserPhotoInQQ() {
   modifyUserPhotoDialog.dismiss();
   processDialog.show();
   modifyUserPhotoInThird(qq_photo_url);
 }
 @Override
 public void onRequestError(String reqID, Exception error) {
   if (processDialog != null && processDialog.isShowing()) {
     processDialog.dismiss();
   }
 }
  @Override
  public void onRequestFinished(String reqId) {

    if (reqId.equals(kREQ_ID_findUserAccountManagerDTOByUserId)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_updateImgInUserHomePage)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_bindQQAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_bindWeiboAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_bindWechatAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }

    if (reqId.equals(kREQ_ID_unbindQQAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_unbindWeiboAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_unbindWechatAccount)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    if (reqId.equals(kREQ_ID_bindThirdPortrait)) {
      if (processDialog != null && processDialog.isShowing()) {
        processDialog.dismiss();
      }
    }
    // if (reqId.equals(kREQ_ID_findThirdImgURLDTOByUserId))
    // processDialog.dismiss();

  }