Commit 6cc2e05f by 郑娜伟

net 1.1.7

parent ee1c7909
......@@ -21,12 +21,12 @@ dependencies {
api 'com.sobot.library:utils:1.1.1'
api 'com.sobot.library:picture:1.1.4'
api 'com.sobot.library:net:1.1.5'
api 'com.sobot.library:net:1.1.7'
api 'com.sobot.library:gson:1.1.1'
// api 'com.sobot.library:utils:1.1.1'
// api 'com.sobot.library:picture_x:1.1.4'
// api 'com.sobot.library:net:1.1.5'
// api 'com.sobot.library:net:1.1.7'
// api 'com.sobot.library:gson:1.1.1'
}
......
......@@ -11,7 +11,7 @@ android {
//这里就是打jar包
task makeJar(type: Copy) {
//删除旧的jar包
delete 'build/libs/sobot_net_1.1.6.jar'
delete 'build/libs/sobot_net_1.1.7.jar'
//原地址
from('build/intermediates/packaged-classes/release/')
//导出jar包的地址
......@@ -19,7 +19,7 @@ android {
//包含的jar包
include('classes.jar')
//重命名jar包为mysdk
rename ('classes.jar', 'sobot_net_1.1.6.jar')
rename ('classes.jar', 'sobot_net_1.1.7.jar')
}
makeJar.dependsOn(build)
}
......
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'net' //项目名
PUBLISH_VERSION = '1.1.6' //版本号
PUBLISH_VERSION = '1.1.7' //版本号
}
......
......@@ -20,7 +20,7 @@ import okhttp3.Call;
import okhttp3.Response;
/**
* 上传任务类
* 上传任务类
*/
public class SobotUploadTask<T> implements Runnable {
private static final String TAG = "SobotUploadTask";
......@@ -101,7 +101,7 @@ public class SobotUploadTask<T> implements Runnable {
// throw new IllegalStateException("you must call SobotUploadTask#save() before SobotUploadTask#start()!");
// }
if (SobotUpload.getInstance().getTask(progress.tag) == null) {
Log.i(TAG,"you must call SobotUploadTask#save() before SobotUploadTask#start()!");
Log.i(TAG, "you must call SobotUploadTask#save() before SobotUploadTask#start()!");
}
if (progress.status != SobotProgress.WAITING && progress.status != SobotProgress.LOADING) {
postOnStart(progress);
......@@ -109,7 +109,7 @@ public class SobotUploadTask<T> implements Runnable {
priorityRunnable = new PriorityRunnable(progress.priority, this);
executor.execute(priorityRunnable);
} else {
Log.w(TAG,"the task with tag " + progress.tag + " is already in the upload queue, current task status is " + progress.status);
Log.w(TAG, "the task with tag " + progress.tag + " is already in the upload queue, current task status is " + progress.status);
}
return this;
}
......@@ -124,7 +124,9 @@ public class SobotUploadTask<T> implements Runnable {
start();
}
/** 暂停的方法 */
/**
* 暂停的方法
*/
public void pause() {
executor.remove(priorityRunnable);
if (progress.status == SobotProgress.WAITING) {
......@@ -133,11 +135,13 @@ public class SobotUploadTask<T> implements Runnable {
progress.speed = 0;
progress.status = SobotProgress.PAUSE;
} else {
Log.w(TAG,"only the task with status WAITING(1) or LOADING(2) can pause, current status is " + progress.status);
Log.w(TAG, "only the task with status WAITING(1) or LOADING(2) can pause, current status is " + progress.status);
}
}
/** 删除一个任务,会删除下载文件 */
/**
* 删除一个任务,会删除下载文件
*/
public SobotUploadTask<T> remove() {
pause();
// UploadManager.getInstance().delete(progress.tag);
......@@ -178,16 +182,22 @@ public class SobotUploadTask<T> implements Runnable {
String resultStr = null;
try {
resultStr = response.body().string();
SobotNetLogUtils.i("uploadFile----->:"+resultStr);
SobotNetLogUtils.i("uploadFile----->:" + resultStr);
final SobotUploadModel result = SobotCommonGsonUtil.jsonToCommonModel(resultStr);
if (result != null && "1".equals(result.getCode()) && result.getData() != null) {
SobotUploadModelBase data = result.getData();
UploadFileResult tmpData = SobotCommonGsonUtil.obtainUploadFileResult(data.getMsg());
if (tmpData != null && !TextUtils.isEmpty(tmpData.getMsgId())) {
// 解析msgid
progress.tag = tmpData.getMsgId();
progress.url = tmpData.getUrl();
postOnFinish(progress, data);
if (result != null) {
if ("1".equals(result.getCode())) {
if (result.getData() != null) {
SobotUploadModelBase data = result.getData();
UploadFileResult tmpData = SobotCommonGsonUtil.obtainUploadFileResult(data.getMsg());
if (tmpData != null && !TextUtils.isEmpty(tmpData.getMsgId())) {
// 解析msgid
progress.tag = tmpData.getMsgId();
progress.url = tmpData.getUrl();
postOnFinish(progress, data);
} else {
postOnError(progress, new RuntimeException(result.getMsg()));
}
}
} else {
postOnError(progress, new RuntimeException(result.getMsg()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment