本文整理汇总了Java中com.qiniu.android.http.ResponseInfo类的典型用法代码示例。如果您正苦于以下问题:Java ResponseInfo类的具体用法?Java ResponseInfo怎么用?Java ResponseInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResponseInfo类属于com.qiniu.android.http包,在下文中一共展示了ResponseInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadApply
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
public void uploadApply(final String certificate, final String name, final String position, final String introduction, final String investorsProjects){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("certificate", certificate);
params.addBodyParameter("name", name);
params.addBodyParameter("position", position);
params.addBodyParameter("introduction", introduction);
params.addBodyParameter("investorsProjects", investorsProjects);
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.POST, "http://116.62.228.37:8000/mine/investors", params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
Toast.makeText(delegate.getActivity(), "已提交申请", Toast.LENGTH_SHORT).show();
delegate.setStatus(3);
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("uploadFiles failed", delegate.getActivity());
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例2: uploadphoto
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
public void uploadphoto(File file) {
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
ImgPath = BuildConfig.QiniuBase+ res.getString("key");
delegate.setmImgAdd(ImgPath);
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}
示例3: upload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void upload(String uploadToken, File avatarFile) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
final String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
otherLogin(fileKey); // 新用户登录
}
}
}, null);
}
示例4: updateAvatarToQiniu
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void updateAvatarToQiniu(File avatarFile) {
UploadManager uploadManager = new UploadManager();
// 指定七牛服务上的文件名
final String genKey = AppUtility.generateUUID();
Logger.d(genKey);
String token = QiniuHelper.getUpToken();
uploadManager.put(avatarFile, genKey, token,
new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
// res 包含hash、key等信息,具体字段取决于上传策略的设置。
Logger.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
updateAvatarKey(genKey);
}
}, null);
}
示例5: upload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void upload(String uploadToken, final File avatarFile, final int type) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
Logger.d(fileKey);
if (type == 0) {//修改头像
updateAvatarKey(fileKey, avatarFile);
} else if (type == 1) {//修改背景墙
updateBackGroud(fileKey, avatarFile);
}
}
}
}, null);
}
示例6: upload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void upload(String uploadToken, File avatarFile) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
Logger.d(fileKey);
updateAvatarKey(fileKey);
}
}
}, null);
}
示例7: imgUpload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
/**
* 通过七牛上传文件
*/
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);
}
}
});
}
示例8: imgUpload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
/**
* 通过七牛上传图片
*/
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);
}
}
});
}
示例9: imgUpload
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
/**
* 通过七牛上传图片
*/
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);
}
}
});
}
示例10: doInBackground
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
@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;
}
示例11: uploadPortrait
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
/**
* 上传头像
*/
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);
}
示例12: ResumeUploader
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
ResumeUploader(Client client, Configuration config, File f, String key, UpToken token, final
UpCompletionHandler completionHandler, UploadOptions options, String recorderKey) {
this.client = client;
this.config = config;
this.f = f;
this.recorderKey = recorderKey;
this.size = (int) f.length();
this.key = key;
this.headers = new StringMap().put("Authorization", "UpToken " + token.token);
this.completionHandler = new UpCompletionHandler() {
public void complete(String key, ResponseInfo info, JSONObject response) {
if (ResumeUploader.this.file != null) {
try {
ResumeUploader.this.file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
completionHandler.complete(key, info, response);
}
};
if (options == null) {
options = UploadOptions.defaultOptions();
}
this.options = options;
this.chunkBuffer = new byte[config.chunkSize];
this.contexts = new String[((int) ((long) (((this.size + Configuration.BLOCK_SIZE) - 1) /
Configuration.BLOCK_SIZE)))];
this.modifyTime = f.lastModified();
this.token = token;
}
示例13: run
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
public void run() {
int offset = recoveryFromRecord();
try {
this.file = new RandomAccessFile(this.f, "r");
nextTask(offset, 0, this.config.up.address);
} catch (FileNotFoundException e) {
e.printStackTrace();
this.completionHandler.complete(this.key, ResponseInfo.fileError(e), null);
}
}
示例14: makeBlock
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void makeBlock(URI address, int offset, int blockSize, int chunkSize, ProgressHandler
progress, CompletionHandler _completionHandler, UpCancellationSignal c) {
String path = String.format(Locale.ENGLISH, "/mkblk/%d", new Object[]{Integer.valueOf
(blockSize)});
try {
this.file.seek((long) offset);
this.file.read(this.chunkBuffer, 0, chunkSize);
this.crc32 = Crc32.bytes(this.chunkBuffer, 0, chunkSize);
post(newURI(address, path), this.chunkBuffer, 0, chunkSize, progress,
_completionHandler, c);
} catch (IOException e) {
this.completionHandler.complete(this.key, ResponseInfo.fileError(e), null);
}
}
示例15: putChunk
import com.qiniu.android.http.ResponseInfo; //导入依赖的package包/类
private void putChunk(URI address, int offset, int chunkSize, String context, ProgressHandler
progress, CompletionHandler _completionHandler, UpCancellationSignal c) {
int chunkOffset = offset % Configuration.BLOCK_SIZE;
String path = String.format(Locale.ENGLISH, "/bput/%s/%d", new Object[]{context, Integer
.valueOf(chunkOffset)});
try {
this.file.seek((long) offset);
this.file.read(this.chunkBuffer, 0, chunkSize);
this.crc32 = Crc32.bytes(this.chunkBuffer, 0, chunkSize);
post(newURI(address, path), this.chunkBuffer, 0, chunkSize, progress,
_completionHandler, c);
} catch (IOException e) {
this.completionHandler.complete(this.key, ResponseInfo.fileError(e), null);
}
}