Commit 6cc2e05f by 郑娜伟

net 1.1.7

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