|
|
@ -22,11 +22,13 @@ import butterknife.OnClick; |
|
|
|
import com.arialyy.annotations.Upload; |
|
|
|
import com.arialyy.annotations.Upload; |
|
|
|
import com.arialyy.aria.core.Aria; |
|
|
|
import com.arialyy.aria.core.Aria; |
|
|
|
import com.arialyy.aria.core.upload.UploadTask; |
|
|
|
import com.arialyy.aria.core.upload.UploadTask; |
|
|
|
|
|
|
|
import com.arialyy.frame.util.FileUtil; |
|
|
|
import com.arialyy.frame.util.show.L; |
|
|
|
import com.arialyy.frame.util.show.L; |
|
|
|
import com.arialyy.simple.R; |
|
|
|
import com.arialyy.simple.R; |
|
|
|
import com.arialyy.simple.base.BaseActivity; |
|
|
|
import com.arialyy.simple.base.BaseActivity; |
|
|
|
import com.arialyy.simple.databinding.ActivityUploadBinding; |
|
|
|
import com.arialyy.simple.databinding.ActivityUploadBinding; |
|
|
|
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; |
|
|
|
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by Aria.Lao on 2017/2/9. |
|
|
|
* Created by Aria.Lao on 2017/2/9. |
|
|
@ -35,7 +37,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> { |
|
|
|
private static final String TAG = "HttpUploadActivity"; |
|
|
|
private static final String TAG = "HttpUploadActivity"; |
|
|
|
@Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; |
|
|
|
@Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; |
|
|
|
|
|
|
|
|
|
|
|
private static final String FILE_PATH = "/mnt/sdcard/360sicheck.txt"; |
|
|
|
private static final String FILE_PATH = "/mnt/sdcard/test.txt"; |
|
|
|
|
|
|
|
|
|
|
|
@Override protected int setLayoutId() { |
|
|
|
@Override protected int setLayoutId() { |
|
|
|
return R.layout.activity_upload; |
|
|
|
return R.layout.activity_upload; |
|
|
@ -48,12 +50,11 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@OnClick(R.id.upload) void upload() { |
|
|
|
@OnClick(R.id.upload) void upload() { |
|
|
|
Aria.upload(HttpUploadActivity.this) |
|
|
|
Aria.upload(HttpUploadActivity.this).load(FILE_PATH) |
|
|
|
.load(FILE_PATH) |
|
|
|
//.setUploadUrl(
|
|
|
|
.setUploadUrl( |
|
|
|
// "http://lib-test.xzxyun.com:8042/Api/upload?data={\"type\":\"1\",\"fileType\":\".txt\"}")
|
|
|
|
"http://lib-test.xzxyun.com:8042/Api/upload?data={\"type\":\"1\",\"fileType\":\".txt\"}") |
|
|
|
.setUploadUrl("http://192.168.1.6:8080/upload/sign_file/").setAttachment("file") |
|
|
|
.setAttachment("file") |
|
|
|
//.addHeader("iplanetdirectorypro", "11a09102fb934ad0bc206f9c611d7933")
|
|
|
|
.addHeader("iplanetdirectorypro", "") |
|
|
|
|
|
|
|
.start(); |
|
|
|
.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -69,7 +70,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Upload.onTaskStart public void taskStart(UploadTask task) { |
|
|
|
@Upload.onTaskStart public void taskStart(UploadTask task) { |
|
|
|
L.d(TAG, "upload start"); |
|
|
|
L.d(TAG, "upload start,md5:" + FileUtil.getFileMD5(new File(task.getEntity().getFilePath()))); |
|
|
|
getBinding().setFileSize(task.getConvertFileSize()); |
|
|
|
getBinding().setFileSize(task.getConvertFileSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,6 +94,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> { |
|
|
|
|
|
|
|
|
|
|
|
@Upload.onTaskComplete public void taskComplete(UploadTask task) { |
|
|
|
@Upload.onTaskComplete public void taskComplete(UploadTask task) { |
|
|
|
L.d(TAG, "上传完成"); |
|
|
|
L.d(TAG, "上传完成"); |
|
|
|
|
|
|
|
L.d(TAG, "上传成功返回数据(如果有的话):" + task.getEntity().getResponseStr()); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
getBinding().setProgress(100); |
|
|
|
getBinding().setProgress(100); |
|
|
|
} |
|
|
|
} |
|
|
|