处理下载网络异常导致的奔溃问题,和奔溃后进入助手下载状态显示错误问题

This commit is contained in:
huangzhuanghua
2016-09-23 18:14:20 +08:00
parent 39350b2cfb
commit 5e44460112
17 changed files with 327 additions and 201 deletions

View File

@ -204,7 +204,7 @@ public class FileUtils {
}
// 上传文件
public static String uploadFile(String url, String filePath, String token) {
public static JSONObject uploadFile(String url, String filePath, String token) {
String end = "\r\n";
String twoHyphens = "--";
String boundary = UUID.randomUUID().toString().replaceAll("-", "")
@ -280,10 +280,15 @@ public class FileUtils {
// 显示网页响应内容
Utils.log("content = " + b.toString().trim());
// {"icon":"http:\/\/api.ghzhushou.com\/temp\/5688e548d7859e6f278b4567.jpg"}
// {"icon":"http:\/\/gh-test-1.oss-cn-qingdao.aliyuncs.com\/pic\/57e4f4d58a3200042d29492f.jpg"}
if (connection.getResponseCode() == HttpStatus.SC_OK) {
JSONObject response = new JSONObject(b.toString().trim());
return response.getString("icon");
response.put("statusCode", HttpStatus.SC_OK);
return response;
} else if (connection.getResponseCode() == HttpStatus.SC_FORBIDDEN) {
JSONObject response = new JSONObject(b.toString().trim());
response.put("statusCode", HttpStatus.SC_FORBIDDEN);
return response;
}
} catch (Exception e) {
// 显示异常信息