com.qiniu.android.http.ResponseInfo Java Examples

The following examples show how to use com.qiniu.android.http.ResponseInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordActivity.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 通过七牛上传文件
 */
private void imgUpload() {
    mViewModel.upLoad(new UpCompletionHandler() {
        @Override
        public void complete(String key, ResponseInfo info,
                             JSONObject response) {
            if (info.isOK()) {
                httpCoachInfo();
            } else {
                dismissProgressDialog();
                Logger.e("imgUpload", info.error);
                UIHelper.shortToast(info.error);
            }
        }
    });
}
 
Example #2
Source File: AvatarActivity.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 通过七牛上传图片
 */
private void imgUpload() {
    mViewModel.upLoad(new UpCompletionHandler() {
        @Override
        public void complete(String key, ResponseInfo info,
                             JSONObject response) {
            if (info.isOK()) {
                httpUserInfo();
            } else {
                dismissProgressDialog();
                Logger.e("imgUpload", info.error);
                UIHelper.shortToast(info.error);
            }
        }
    });
}
 
Example #3
Source File: QrCodeActivity.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 通过七牛上传图片
 */
private void imgUpload() {
    mViewModel.upLoad(new UpCompletionHandler() {
        @Override
        public void complete(String key, ResponseInfo info,
                             JSONObject response) {
            if (info.isOK()) {
                httpCoachInfo();
            } else {
                dismissProgressDialog();
                Logger.e("imgUpload", info.error);
                UIHelper.shortToast(info.error);
            }
        }
    });
}
 
Example #4
Source File: UserInfoActivity.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 通过七牛上传图片
 */
private void imgUpload() {
    mViewModel.upLoad(new UpCompletionHandler() {
        @Override
        public void complete(String key, ResponseInfo info,
                             JSONObject response) {
            if (info.isOK()) {
                httpUserInfo();
            } else {
                dismissProgressDialog();
                Logger.e("imgUpload", info.error);
                UIHelper.shortToast(info.error);
            }
        }
    });
}
 
Example #5
Source File: QiniuUtils.java    From Luban-Circle-Demo with Apache License 2.0 6 votes vote down vote up
@Override
protected String doInBackground() {
    uploadManager.put(file, null, token,
            new UpCompletionHandler() {
                @Override
                public void complete(String key, ResponseInfo info, JSONObject response) {
                    try {
                        if (info.statusCode == 200) {
                            // 上传图片返回key值
                            callback.onSuccess(file, JsonUtils.getString("key", response));
                        } else {
                            callback.onError(info.statusCode);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        callback.onError(1);
                    }
                }
            }, null);
    return null;
}
 
Example #6
Source File: CreateUserInfoActivity.java    From QiQuYing with Apache License 2.0 6 votes vote down vote up
/**
 * 上传头像
 */
private void uploadPortrait() {
	if(mKeyToken == null) {
		ToastUtils.showMessage(getApplicationContext(), R.string.set_portrait_fail);
		return;
	}
	UploadManager uploadManager = new UploadManager();
	File file = new File(Environment.getExternalStorageDirectory()
			+ "/" + IMAGE_FILE_NAME);
	uploadManager.put(file, mKeyToken.getKey(),
			mKeyToken.getToken(), new UpCompletionHandler() {
				@Override
				public void complete(String fileName, ResponseInfo responseInfo,
						JSONObject jsonObject) {
					mPortraitURL = Constants.UPLOADFILE_PRE + fileName;
					if (responseInfo.isOK()) {
						//上传成功,更新用户头像
						mUserService.setPortrait(mHandler, String.valueOf(App.currentUser.getId()), mPortraitURL);
					} else {
						ToastUtils.showMessage(getApplicationContext(),
								R.string.set_portrait_fail);
						ProgressDialogUtils.dismiss();
					}
				}
			}, null);
}
 
Example #7
Source File: UserInfoActivity.java    From QiQuYing with Apache License 2.0 6 votes vote down vote up
/**
 * 上传头像
 */
private void uploadPortrait() {
	if(mKeyToken == null) {
		ToastUtils.showMessage(getApplicationContext(), R.string.set_portrait_fail);
		return;
	}
	UploadManager uploadManager = new UploadManager();
	File file = new File(Environment.getExternalStorageDirectory()
			+ "/" + IMAGE_FILE_NAME);
	uploadManager.put(file, mKeyToken.getKey(),
			mKeyToken.getToken(), new UpCompletionHandler() {
				@Override
				public void complete(String fileName, ResponseInfo responseInfo,
						JSONObject jsonObject) {
					mPortraitURL = Constants.UPLOADFILE_PRE + fileName;
					if (responseInfo.isOK()) {
						//上传成功,更新用户头像
						mUserService.setPortrait(mHandler, String.valueOf(App.currentUser.getId()), mPortraitURL);
					} else {
						ToastUtils.showMessage(getApplicationContext(),
								R.string.set_portrait_fail);
						ProgressDialogUtils.dismiss();
					}
				}
			}, null);
}