/** 初始化界面控件 */
  @SuppressWarnings("deprecation")
  private void initialView() {
    userinfoChangeImage_rl = (RelativeLayout) findViewById(R.id.userinfoChangeImage_rl);
    userinfoChangeImage_rl.setOnClickListener(this);
    userConfigChangeReturn = (ImageView) findViewById(R.id.userConfigChangeReturn);
    userConfigChangeReturn.setOnClickListener(this);
    userImage = (ImageView) findViewById(R.id.userinfoChangeImage);
    userImage.setOnClickListener(this);
    userinfo_change_nickname_rl = (RelativeLayout) findViewById(R.id.userinfo_change_nickname_rl);
    userinfo_change_nickname_rl.setOnClickListener(this);
    userinfo_change_weixin_rl = (RelativeLayout) findViewById(R.id.userinfo_change_weixin_rl);
    userinfo_change_weixin_rl.setOnClickListener(this);
    userinfo_change_weibo_rl = (RelativeLayout) findViewById(R.id.userinfo_change_weibo_rl);
    userinfo_change_weibo_rl.setOnClickListener(this);
    userinfo_change_pwd_rl = (RelativeLayout) findViewById(R.id.userinfo_change_pwd_rl);
    userinfo_change_pwd_rl.setOnClickListener(this);

    userinfo_change_nickname = (TextView) findViewById(R.id.userinfo_change_nickname);
    userinfo_change_phone = (TextView) findViewById(R.id.userinfo_change_phone);

    if (!MySharePreference.getValueFromKey(UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME)
            .equals(MySharePreference.NOTSTATE)
        && !MySharePreference.getValueFromKey(
                UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME)
            .equals("null")) {
      userinfo_change_nickname.setText(
          MySharePreference.getValueFromKey(
              UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME));
    } else {
      userinfo_change_nickname.setText(
          StringUtil.getNickNameFromPhone(
              MySharePreference.getValueFromKey(
                  UserInfoActivity.this, MySharePreference.LOGINSTATE)));
    }
    userinfo_change_phone.setText(
        MySharePreference.getValueFromKey(UserInfoActivity.this, MySharePreference.LOGINSTATE));
    String imageHeadUrl = "";
    if (MySharePreference.getValueFromKey(UserInfoActivity.this, MySharePreference.ACCOUNTAVATAR)
        .equals(MySharePreference.NOTSTATE)) {
      imageHeadUrl = YunTongXun.UserHeadImageDefault;
    } else {
      imageHeadUrl =
          MySharePreference.getValueFromKey(UserInfoActivity.this, MySharePreference.ACCOUNTAVATAR);
    }
    final String imageurlFinal = imageHeadUrl;
    userImage.setTag(imageurlFinal);
    ImageDownloadHelper.getInstance()
        .imageDownload(
            null,
            UserInfoActivity.this,
            imageurlFinal,
            userImage,
            "/001yunhekeji100",
            new OnImageDownloadListener() {
              public void onImageDownload(Bitmap bitmap, String imgUrl) {
                if (bitmap != null) {
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    userImage.setBackground(new BitmapDrawable(bitmap));
                  } else {
                    userImage.setBackgroundDrawable(new BitmapDrawable(bitmap));
                  }

                  userImage.setTag(
                      YunTongXun.ImagePath + StringUtil.getFileNameFromUrl(imageurlFinal));
                } else {
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    userImage.setBackground(
                        new BitmapDrawable(
                            ImageUtils.toRoundBitmap(
                                BitmapFactory.decodeResource(
                                    getResources(), R.drawable.user_head))));
                  } else {
                    userImage.setBackgroundDrawable(
                        new BitmapDrawable(
                            ImageUtils.toRoundBitmap(
                                BitmapFactory.decodeResource(
                                    getResources(), R.drawable.user_head))));
                  }
                }
              }
            });
  }
  @SuppressWarnings("deprecation")
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RESULT_LOAD_IMAGE_BG_phone && resultCode == RESULT_OK) {
      Uri selectedImage = data.getData();
      Intent intent = new Intent();
      intent.setAction("com.android.camera.action.CROP");
      intent.setDataAndType(selectedImage, "image/*"); // mUri是已经选择的图片Uri
      intent.putExtra("crop", "true");
      intent.putExtra("aspectX", 1); // 裁剪框比例
      intent.putExtra("aspectY", 1);
      intent.putExtra("outputX", 150); // 输出图片大小
      intent.putExtra("outputY", 150);
      intent.putExtra("circleCrop", "");
      intent.putExtra("return-data", true);
      startActivityForResult(intent, 200);
    }
    if (resultCode == RESULT_OK && requestCode == RESULT_LOAD_IMAGE_BG_camera) {
      File picture = new File(Environment.getExternalStorageDirectory(), "yuhekeji.png");
      Intent intent = new Intent("com.android.camera.action.CROP");
      intent.setDataAndType(Uri.fromFile(picture), "image/*");
      // 下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
      intent.putExtra("crop", "true");
      // aspectX aspectY 是宽高的比例
      intent.putExtra("aspectX", 1);
      intent.putExtra("aspectY", 1);
      // outputX outputY 是裁剪图片宽高
      intent.putExtra("outputX", 150);
      intent.putExtra("outputY", 150);
      intent.putExtra("return-data", true);
      startActivityForResult(intent, 200);
    }

    if (requestCode == 200 && resultCode == RESULT_OK) {
      Bitmap bmap = data.getParcelableExtra("data");
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inSampleSize = 1;
      String nameTime = UUID.randomUUID().toString() + ".png";
      ImageUtils.saveMyBitmap(nameTime, ImageUtils.toRoundBitmap(bmap));
      userImage.setTag(YunTongXun.ImagePath + nameTime);
      String userPara = "avatar=" + userImage.getTag().toString();
      dg = MainFragment.createLoadingDialog(this);
      dg.show();
      NetConnectionLoginZhuCe.ModifyPutNetConnection(
          NetUrls.URL_MODIFY_USERINFO
              + MySharePreference.getValueFromKey(
                  UserInfoActivity.this, MySharePreference.ACCOUNTID)
              + "/",
          userPara,
          "Token "
              + MySharePreference.getValueFromKey(
                  UserInfoActivity.this, MySharePreference.ACCOUNTTOKEN),
          new ZhuceSuccessCallBack() {
            @Override
            public void onSuccess(HashMap<String, Object> result) {
              dg.dismiss();
              if (result != null) {
                if (result.keySet().contains("status_code")) {
                  ErrorMarkToast.showCallBackToast(UserInfoActivity.this, result);
                  return;
                }
                ImageUtils.fileReName(
                    StringUtil.getFileNameFromUrl(userImage.getTag().toString()),
                    StringUtil.getFileNameFromUrl(
                        result.get(MySharePreference.ACCOUNTAVATAR).toString()));
                result.put(MySharePreference.ACCOUNTID, result.get("user").toString());
                MySharePreference.saveAccountModifyInfo(UserInfoActivity.this, result);
                String imageHeadUrl;
                if (MySharePreference.getValueFromKey(
                        UserInfoActivity.this, MySharePreference.ACCOUNTAVATAR)
                    .equals(MySharePreference.NOTSTATE)) {
                  imageHeadUrl = YunTongXun.UserHeadImageDefault;
                } else {
                  imageHeadUrl =
                      MySharePreference.getValueFromKey(
                          UserInfoActivity.this, MySharePreference.ACCOUNTAVATAR);
                }
                final String imageurlFinal = imageHeadUrl;
                userImage.setTag(imageurlFinal);
                ImageDownloadHelper.getInstance()
                    .imageDownload(
                        null,
                        UserInfoActivity.this,
                        imageurlFinal,
                        userImage,
                        "/001yunhekeji100",
                        new OnImageDownloadListener() {
                          public void onImageDownload(Bitmap bitmap, String imgUrl) {
                            if (bitmap != null) {
                              if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                                userImage.setBackground(new BitmapDrawable(bitmap));
                              } else {
                                userImage.setBackgroundDrawable(new BitmapDrawable(bitmap));
                              }
                              userImage.setTag(
                                  YunTongXun.ImagePath
                                      + StringUtil.getFileNameFromUrl(imageurlFinal));
                            } else {
                              if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                                userImage.setBackground(
                                    new BitmapDrawable(
                                        ImageUtils.toRoundBitmap(
                                            BitmapFactory.decodeResource(
                                                getResources(), R.drawable.user_head))));
                              } else {
                                userImage.setBackgroundDrawable(
                                    new BitmapDrawable(
                                        ImageUtils.toRoundBitmap(
                                            BitmapFactory.decodeResource(
                                                getResources(), R.drawable.user_head))));
                              }
                            }
                          }
                        });

              } else {
                showToast(R.string.interneterror);
              }
            }
          });
    }

    if (requestCode == 10) {
      if (!MySharePreference.getValueFromKey(
                  UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME)
              .equals(MySharePreference.NOTSTATE)
          && !MySharePreference.getValueFromKey(
                  UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME)
              .equals("null")) {
        userinfo_change_nickname.setText(
            MySharePreference.getValueFromKey(
                UserInfoActivity.this, MySharePreference.ACCOUNTNICKNAME));
      } else {
        userinfo_change_nickname.setText(
            StringUtil.getNickNameFromPhone(
                MySharePreference.getValueFromKey(
                    UserInfoActivity.this, MySharePreference.LOGINSTATE)));
      }
    }
  }