com.qiniu.android.storage.UpCompletionHandler Java Examples

The following examples show how to use com.qiniu.android.storage.UpCompletionHandler. 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);
}
 
Example #8
Source File: QiNiuUtil.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
public void qiNiuUpLoad(String token, String key, String filePath,
                        UpCompletionHandler callBack, UpProgressHandler progressHandler) {
    // 获得
    if (filePath == null || filePath.isEmpty()) {
        Logger.e("upLoad", "地址为空");
        return;
    }
    Map<String, String> map = new HashMap<>();
    // 上传
    uploadManager.put(filePath, key, token,
            callBack, new UploadOptions(map, null, false, progressHandler
                    , null));
}
 
Example #9
Source File: QiNiuUtil.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
public void qiNiuUpLoad(String token, String key, String filePath,
                        UpCompletionHandler callBack) {
    qiNiuUpLoad(token, key, filePath, callBack, null);
    // 上传
}
 
Example #10
Source File: PhotoWallModel.java    From Android-Application-ZJB with Apache License 2.0 2 votes vote down vote up
/**
 * 通过七牛 上传文件
 *
 * @param
 */
public void upLoad(String token, String eTag, String filePath, UpCompletionHandler upCompletionHandler) {
    QiNiuUtil.getInstance().qiNiuUpLoad(token, eTag,
            filePath, upCompletionHandler, null);
}
 
Example #11
Source File: UpLoadModel.java    From Android-Application-ZJB with Apache License 2.0 2 votes vote down vote up
/**
 * 通过七牛 上传文件
 *
 * @param upCompletionHandler
 */
public void upLoad(UpCompletionHandler upCompletionHandler) {
    QiNiuUtil.getInstance().qiNiuUpLoad(mQiNiuToken, mEtagKey,
            mQiNiuFilePath, upCompletionHandler, null);
}