Exemple #1
0
 @Override
 public void doFinish(String path, String url) {
   if (!TextUtils.isEmpty(url)) {
     pair = new Pair<String, String>(path, url);
     L.d("url----" + url);
   }
 }
Exemple #2
0
 @Override
 public void onResponse(String response) {
   L.d(response);
   dismissLoadingDialog();
   BaseResponse<UserInfo> _respone =
       new Gson().fromJson(response, new TypeToken<BaseResponse<UserInfo>>() {}.getType());
   if (_respone.retcode != 0) {
     ToastUtil.show(_respone.showmsg);
   } else {
     _respone.retbody.chkcode = _respone.chkcode;
     IMApplication.getApplication().savechkcode(_respone.chkcode);
     IMApplication.getApplication().saveUserInfo(_respone.retbody);
     ToastUtil.show("编辑资料成功");
     setResult(RESULT_OK);
     finish();
   }
 }
Exemple #3
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    dismissMenu();
    if (RESULT_OK != resultCode) {
      return;
    }
    switch (requestCode) {
      case OPEN_PIC:
        L.d("---OPEN_PIC---" + data.getData().toString());
        if (data != null) {
          mFileUri = data.getData();
          String _imgPath = getPath(this, mFileUri);
          L.d("onActivityResult()--->imgPath=" + _imgPath);
          L.d("MSG", "onActivityResult()--->Uri=" + mFileUri.toString());
          if (!TextUtils.isEmpty(_imgPath)) {
            // path转Uri 会把中文编码,导致图片无法加载,故需要将uri解码,图片才可以正常显示
            //                        mAdapter.addPhoto();
            curPath = _imgPath;
            pair = new Pair<String, String>("", "");
            IMApplication.getApplication()
                .displayImage(
                    Uri.decode(Uri.fromFile(new File(_imgPath)).toString()), getImageView());
            new UploadPic(_imgPath, listener).execute();
          }
        }
        break;
      case OPEN_PIC_KITKAT:
        L.d("---OPEN_PIC_KITKAT---" + data.getData().toString());
        if (data != null) {
          mFileUri = data.getData();

          String imgPath = getPath(this, mFileUri);
          L.d("onActivityResult()--->imgPath=" + imgPath);
          L.d("MSG", "onActivityResult()--->Uri=" + mFileUri.toString());
          if (!TextUtils.isEmpty(imgPath)) {
            curPath = imgPath;
            pair = new Pair<String, String>("", "");
            // path转Uri 会把中文编码,导致图片无法加载,故需要将uri解码,图片才可以正常显示
            //                        mAdapter.addPhoto(Uri.decode(Uri.fromFile(new
            // File(imgPath)).toString()));
            IMApplication.getApplication()
                .displayImage(
                    Uri.decode(Uri.fromFile(new File(imgPath)).toString()), getImageView());
            new UploadPic(imgPath, listener).execute();
          }
        }
        break;
      case OPEN_CAMERA_CODE:
        final String path = mFileUri == null ? "" : mFileUri.getPath();
        if (!TextUtils.isEmpty(path) && new File(path).exists()) {
          // path转Uri 会把中文编码,导致图片无法加载,故需要将uri解码,图片才可以正常显示
          //                    mAdapter.addPhoto(Uri.decode(Uri.fromFile(new
          // File(path)).toString()));
          cropPhoto(mFileUri);
          //                } else if (data != null && data.hasExtra("data")) {
          //                    Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
          //                    try {
          //                        bitmap.compress(Bitmap.CompressFormat.PNG, 100, new
          // FileOutputStream(path));
          ////                        mAdapter.addPhoto(Uri.decode(Uri.fromFile(new
          // File(path)).toString()));
          //                    } catch (FileNotFoundException e) {
          //                        e.printStackTrace();
          //                    } finally {
          //                    }
        } else {
          ToastUtil.show("无法获取照片!");
        }
        break;
    }
  }