public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case TOOK_AVATAR_BY_CAMERA: // 拍完用户头像照片返回
        if (resultCode == this.RESULT_OK) {

          try {
            String path = GetPathFromUri4kitkat.getPath(this, mImageFileUri);
            avatarBitmap = ImageScale.decodeSampledBitmapFromResource(path); // 压缩图片
            Bitmap circularShapeBitmap =
                CircularCutting.toRoundBitmap(avatarBitmap); // 将bitmap对象设置为圆形
            AccountAvatarIV.setImageBitmap(circularShapeBitmap);
            Uri avatarSaclefileUri =
                saveAvatarBitmap2Saclefile(avatarBitmap, "scaleImage", "avatar.jpg"); // 保存bitmap成图片
            WaitingProcessDialog.showRoundProcessDialog(
                AccountAndSecurityActivity.this, "正在上傳頭像...");
            uploadHeadImgPost(avatarSaclefileUri);
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
        break;
      case TOOK_AVATAR_BY_ALBUM: // 从相册中选择完用户头像照片返回
        if (resultCode == RESULT_OK && data != null) {

          try {
            mImageFileUri = data.getData();
            String path = GetPathFromUri4kitkat.getPath(this, mImageFileUri);
            avatarBitmap = ImageScale.decodeSampledBitmapFromResource(path); // 压缩图片
            Bitmap circularShapeBitmap =
                CircularCutting.toRoundBitmap(avatarBitmap); // 将bitmap对象设置为圆形
            AccountAvatarIV.setImageBitmap(circularShapeBitmap);
            Uri avatarSaclefileUri =
                saveAvatarBitmap2Saclefile(avatarBitmap, "scaleImage", "avatar.jpg"); // 保存bitmap成图片
            WaitingProcessDialog.showRoundProcessDialog(
                AccountAndSecurityActivity.this, "正在上傳頭像...");
            uploadHeadImgPost(avatarSaclefileUri);
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
        break;

      case TO_MODIFYNAME:
        nameTV.setText(myApplication.getLoginName());
        name = nameTV.getText().toString();
        break;
    }
  }
  /**
   * 师傅上传新头像图片网络请求
   *
   * @throws Exception
   */
  private void uploadHeadImgPost(Uri uri) throws Exception {
    ApiServices.getAppService()
        .uploadImg(
            new TypedFile("image/jpeg", new File(GetPathFromUri4kitkat.getPath(this, uri))),
            new BaseCallback<ImagePathResponse>(this) {

              @Override
              public void success(ImagePathResponse data, Response response) {
                if (data.getCode().equals("200")) {

                  headImgUpdatePath = data.getData(); // 存储服务器返回的更新头像操作后,头像图片存放的位置
                  try {
                    updateMasterHeadImgPost();
                  } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }

                } else {
                  Toast.makeText(
                          AccountAndSecurityActivity.this, "頭像圖片上傳失敗,請重新選擇圖片", Toast.LENGTH_SHORT)
                      .show();
                }

                super.success(data, response);
              }

              @Override
              public void failure(RetrofitError arg0) {
                super.failure(arg0);
              }
            });
  }