upload,代码重构

pull/330/head
AriaLyy 8 years ago
parent 90c7cd78ff
commit d05b685fa3
  1. 2
      .idea/misc.xml
  2. 21
      Aria/src/main/java/com/arialyy/aria/core/Aria.java
  3. 27
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java
  5. 20
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  6. 8
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  7. 3
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
  8. 9
      Aria/src/main/java/com/arialyy/aria/core/download/command/AddCmd.java
  9. 9
      Aria/src/main/java/com/arialyy/aria/core/download/command/CancelCmd.java
  10. 5
      Aria/src/main/java/com/arialyy/aria/core/download/command/CmdFactory.java
  11. 17
      Aria/src/main/java/com/arialyy/aria/core/download/command/IDownloadCmd.java
  12. 6
      Aria/src/main/java/com/arialyy/aria/core/download/command/SingleCmd.java
  13. 9
      Aria/src/main/java/com/arialyy/aria/core/download/command/StartCmd.java
  14. 10
      Aria/src/main/java/com/arialyy/aria/core/download/command/StopCmd.java
  15. 44
      Aria/src/main/java/com/arialyy/aria/core/download/queue/DownloadTaskQueue.java
  16. 20
      Aria/src/main/java/com/arialyy/aria/core/download/queue/IDownloader.java
  17. 12
      Aria/src/main/java/com/arialyy/aria/core/download/queue/IPool.java
  18. 19
      Aria/src/main/java/com/arialyy/aria/core/download/queue/ITaskQueue.java
  19. 22
      Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/CachePool.java
  20. 30
      Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/ExecutePool.java
  21. 18
      Aria/src/main/java/com/arialyy/aria/core/download/scheduler/DownloadSchedulers.java
  22. 4
      Aria/src/main/java/com/arialyy/aria/core/download/scheduler/IDownloadSchedulers.java
  23. 20
      Aria/src/main/java/com/arialyy/aria/core/download/scheduler/OnSchedulerListener.java
  24. 4
      Aria/src/main/java/com/arialyy/aria/core/download/task/ConnectionHelp.java
  25. 2
      Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadListener.java
  26. 2
      Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadStateConstance.java
  27. 26
      Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTask.java
  28. 24
      Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTaskFactory.java
  29. 6
      Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadUtil.java
  30. 2
      Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadListener.java
  31. 4
      Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadUtil.java
  32. 2
      Aria/src/main/java/com/arialyy/aria/core/download/task/SingleThreadTask.java
  33. 12
      Aria/src/main/java/com/arialyy/aria/core/inf/ICmd.java
  34. 4
      Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java
  35. 11
      Aria/src/main/java/com/arialyy/aria/core/upload/IUploadListener.java
  36. 150
      Aria/src/main/java/com/arialyy/aria/core/upload/MultipartUtility.java
  37. 30
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java
  38. 4
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  39. 22
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java
  40. 122
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java
  41. 27
      Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
  42. 7
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  43. 3
      app/src/main/AndroidManifest.xml
  44. 14
      app/src/main/java/com/arialyy/simple/dialog_task/DownloadDialog.java
  45. 14
      app/src/main/java/com/arialyy/simple/fragment_task/DownloadFragment.java
  46. 2
      app/src/main/java/com/arialyy/simple/module/DownloadModule.java
  47. 18
      app/src/main/java/com/arialyy/simple/multi_task/DownloadActivity.java
  48. 2
      app/src/main/java/com/arialyy/simple/multi_task/DownloadAdapter.java
  49. 12
      app/src/main/java/com/arialyy/simple/multi_task/MultiTaskActivity.java
  50. 14
      app/src/main/java/com/arialyy/simple/notification/SimpleNotification.java
  51. 14
      app/src/main/java/com/arialyy/simple/pop_task/DownloadPopupWindow.java
  52. 22
      app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java
  53. 36
      app/src/main/java/com/arialyy/simple/upload.java
  54. 22
      app/src/main/res/layout/activity_upload.xml

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -26,8 +26,9 @@ import android.app.Service;
import android.content.Context;
import android.os.Build;
import android.widget.PopupWindow;
import com.arialyy.aria.core.scheduler.OnSchedulerListener;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadReceiver;
import com.arialyy.aria.core.download.scheduler.OnSchedulerListener;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/12/1.
@ -143,35 +144,35 @@ import com.arialyy.aria.core.task.Task;
public static class SimpleSchedulerListener implements OnSchedulerListener {
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
}
@Override public void onTaskResume(Task task) {
@Override public void onTaskResume(DownloadTask task) {
}
@Override public void onTaskStart(Task task) {
@Override public void onTaskStart(DownloadTask task) {
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
}
@Override public void onTaskFail(Task task) {
@Override public void onTaskFail(DownloadTask task) {
}
@Override public void onTaskComplete(Task task) {
@Override public void onTaskComplete(DownloadTask task) {
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
}
}

@ -27,9 +27,14 @@ import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.widget.PopupWindow;
import com.arialyy.aria.core.command.download.IDownloadCmd;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.download.command.IDownloadCmd;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadReceiver;
import com.arialyy.aria.core.inf.ICmd;
import com.arialyy.aria.core.inf.IReceiver;
import com.arialyy.aria.core.download.queue.DownloadTaskQueue;
import com.arialyy.aria.core.download.queue.ITaskQueue;
import com.arialyy.aria.core.upload.UploadReceiver;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.orm.DbUtil;
import com.arialyy.aria.util.CAConfiguration;
@ -56,7 +61,7 @@ import java.util.Map;
public static Context APP;
private ITaskQueue mTaskQueue;
private List<IDownloadCmd> mCommands = new ArrayList<>();
private List<ICmd> mCommands = new ArrayList<>();
private AriaManager(Context context) {
DbUtil.init(context.getApplicationContext());
@ -75,7 +80,11 @@ import java.util.Map;
return INSTANCE;
}
List<DownloadEntity> getAllDownloadEntity() {
public Map<String, IReceiver> getReceiver(){
return mReceivers;
}
public List<DownloadEntity> getAllDownloadEntity() {
return DbEntity.findAllData(DownloadEntity.class);
}
@ -89,7 +98,7 @@ import java.util.Map;
/**
* 设置命令
*/
AriaManager setCmd(IDownloadCmd command) {
public AriaManager setCmd(ICmd command) {
mCommands.add(command);
return this;
}
@ -97,7 +106,7 @@ import java.util.Map;
/**
* 设置一组命令
*/
AriaManager setCmds(List<IDownloadCmd> commands) {
public <T extends ICmd> AriaManager setCmds(List<T> commands) {
if (commands != null && commands.size() > 0) {
mCommands.addAll(commands);
}
@ -107,8 +116,8 @@ import java.util.Map;
/**
* 执行所有设置的命令
*/
synchronized void exe() {
for (IDownloadCmd command : mCommands) {
public synchronized void exe() {
for (ICmd command : mCommands) {
command.executeCmd();
}
mCommands.clear();

@ -15,7 +15,7 @@
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.download;
import android.os.Parcel;
import android.os.Parcelable;

@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.download;
import android.support.annotation.NonNull;
import com.arialyy.aria.core.command.download.CmdFactory;
import com.arialyy.aria.core.command.download.IDownloadCmd;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.scheduler.OnSchedulerListener;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.IReceiver;
import com.arialyy.aria.core.download.command.CmdFactory;
import com.arialyy.aria.core.download.command.IDownloadCmd;
import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.download.scheduler.OnSchedulerListener;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;
@ -30,7 +32,7 @@ import java.util.Set;
* Created by lyy on 2016/12/5.
* 下载功能接收器
*/
public class DownloadReceiver implements IReceiver{
public class DownloadReceiver implements IReceiver {
private static final String TAG = "DownloadReceiver";
public String targetName;
public OnSchedulerListener listener;
@ -131,11 +133,11 @@ public class DownloadReceiver implements IReceiver{
CommonUtil.createDownloadCmd(new DownloadTaskEntity(entity), CmdFactory.TASK_CANCEL));
}
ariaManager.setCmds(cancelCmds).exe();
Set<String> keys = ariaManager.mReceivers.keySet();
Set<String> keys = ariaManager.getReceiver().keySet();
for (String key : keys) {
IReceiver receiver = ariaManager.mReceivers.get(key);
IReceiver receiver = ariaManager.getReceiver().get(key);
receiver.removeSchedulerListener();
ariaManager.mReceivers.remove(key);
ariaManager.getReceiver().remove(key);
}
}
}

@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.download;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.arialyy.aria.core.command.download.CmdFactory;
import com.arialyy.aria.core.command.download.IDownloadCmd;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.RequestEnum;
import com.arialyy.aria.core.download.command.CmdFactory;
import com.arialyy.aria.core.download.command.IDownloadCmd;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;

@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.download;
import com.arialyy.aria.core.RequestEnum;
import java.util.HashMap;
import java.util.Map;

@ -14,12 +14,11 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import android.util.Log;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/8/22.
@ -36,7 +35,7 @@ class AddCmd extends IDownloadCmd {
}
@Override public void executeCmd() {
Task task = mQueue.getTask(mEntity.downloadEntity);
DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
if (task == null) {
mQueue.createTask(mTargetName, mEntity);
} else {

@ -14,11 +14,10 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/9/20.
@ -35,7 +34,7 @@ class CancelCmd extends IDownloadCmd {
}
@Override public void executeCmd() {
Task task = mQueue.getTask(mEntity.downloadEntity);
DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
if (task == null) {
task = mQueue.createTask(mTargetName, mEntity);
}

@ -14,10 +14,9 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
/**
* Created by Lyy on 2016/9/23.

@ -14,11 +14,12 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.queue.ITaskQueue;
import com.arialyy.aria.core.inf.ICmd;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
@ -26,7 +27,7 @@ import com.arialyy.aria.util.CommonUtil;
* Created by lyy on 2016/8/22.
* 下载命令
*/
public abstract class IDownloadCmd {
public abstract class IDownloadCmd implements ICmd{
ITaskQueue mQueue;
DownloadTaskEntity mEntity;
String TAG;
@ -43,17 +44,11 @@ public abstract class IDownloadCmd {
* @param targetName 产生任务的对象名
*/
IDownloadCmd(String targetName, DownloadTaskEntity entity) {
if (!CheckUtil.checkDownloadEntity(entity.downloadEntity)) {
return;
}
CheckUtil.checkDownloadEntity(entity.downloadEntity);
mTargetName = targetName;
mEntity = entity;
TAG = CommonUtil.getClassName(this);
mQueue = AriaManager.getInstance(AriaManager.APP).getTaskQueue();
}
/**
* 执行命令
*/
public abstract void executeCmd();
}

@ -16,8 +16,8 @@
//package com.arialyy.aria.core.command.download;
//
//import android.util.Log;
//import com.arialyy.aria.core.DownloadEntity;
//import com.arialyy.aria.core.task.Task;
//import com.arialyy.aria.core.download.DownloadEntity;
//import com.arialyy.aria.core.task.DownloadTask;
//
///**
// * Created by lyy on 2016/11/30.
@ -36,7 +36,7 @@
// }
//
// @Override public void executeCmd() {
// Task task = mQueue.getTask(mEntity);
// DownloadTask task = mQueue.getTask(mEntity);
// if (task == null) {
// task = mQueue.createTask(mTargetName, mEntity);
// } else {

@ -14,11 +14,10 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/8/22.
@ -35,7 +34,7 @@ class StartCmd extends IDownloadCmd {
}
@Override public void executeCmd() {
Task task = mQueue.getTask(mEntity.downloadEntity);
DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
if (task == null) {
task = mQueue.createTask(mTargetName, mEntity);
}

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.arialyy.aria.core.command.download;
package com.arialyy.aria.core.download.command;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/9/20.
@ -37,7 +37,7 @@ class StopCmd extends IDownloadCmd {
}
@Override public void executeCmd() {
Task task = mQueue.getTask(mEntity.downloadEntity);
DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
if (task == null) {
if (mEntity.downloadEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) {
task = mQueue.createTask(mTargetName, mEntity);

@ -14,18 +14,18 @@
* limitations under the License.
*/
package com.arialyy.aria.core.queue;
package com.arialyy.aria.core.download.queue;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.queue.pool.CachePool;
import com.arialyy.aria.core.queue.pool.ExecutePool;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.task.TaskFactory;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.queue.pool.CachePool;
import com.arialyy.aria.core.download.queue.pool.ExecutePool;
import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.core.download.task.DownloadTaskFactory;
import com.arialyy.aria.util.Configuration;
/**
@ -79,7 +79,7 @@ public class DownloadTaskQueue implements ITaskQueue {
return mCachePool.size();
}
@Override public void startTask(Task task) {
@Override public void startTask(DownloadTask task) {
if (mExecutePool.putTask(task)) {
mCachePool.removeTask(task);
task.getDownloadEntity().setFailNum(0);
@ -87,7 +87,7 @@ public class DownloadTaskQueue implements ITaskQueue {
}
}
@Override public void stopTask(Task task) {
@Override public void stopTask(DownloadTask task) {
if (!task.isDownloading()) Log.w(TAG, "停止任务失败,【任务已经停止】");
if (mExecutePool.removeTask(task)) {
task.stop();
@ -97,11 +97,11 @@ public class DownloadTaskQueue implements ITaskQueue {
}
}
@Override public void cancelTask(Task task) {
@Override public void cancelTask(DownloadTask task) {
task.cancel();
}
@Override public void reTryStart(Task task) {
@Override public void reTryStart(DownloadTask task) {
if (task == null) {
Log.w(TAG, "重试下载失败,task 为null");
return;
@ -128,7 +128,7 @@ public class DownloadTaskQueue implements ITaskQueue {
//设置的任务数小于配置任务数
if (diff <= -1 && mExecutePool.size() >= size) {
for (int i = 0, len = Math.abs(diff); i < len; i++) {
Task eTask = mExecutePool.pollTask();
DownloadTask eTask = mExecutePool.pollTask();
if (eTask != null) {
stopTask(eTask);
}
@ -137,7 +137,7 @@ public class DownloadTaskQueue implements ITaskQueue {
mExecutePool.setDownloadNum(downloadNum);
if (diff >= 1) {
for (int i = 0; i < diff; i++) {
Task nextTask = getNextTask();
DownloadTask nextTask = getNextTask();
if (nextTask != null
&& nextTask.getDownloadEntity().getState() == DownloadEntity.STATE_WAIT) {
startTask(nextTask);
@ -146,21 +146,21 @@ public class DownloadTaskQueue implements ITaskQueue {
}
}
@Override public Task createTask(String target, DownloadTaskEntity entity) {
Task task;
@Override public DownloadTask createTask(String target, DownloadTaskEntity entity) {
DownloadTask task;
if (TextUtils.isEmpty(target)) {
task =
TaskFactory.getInstance().createTask(mContext, entity, DownloadSchedulers.getInstance());
DownloadTaskFactory.getInstance().createTask(mContext, entity, DownloadSchedulers.getInstance());
} else {
task = TaskFactory.getInstance()
task = DownloadTaskFactory.getInstance()
.createTask(target, mContext, entity, DownloadSchedulers.getInstance());
}
mCachePool.putTask(task);
return task;
}
@Override public Task getTask(DownloadEntity entity) {
Task task = mExecutePool.getTask(entity.getDownloadUrl());
@Override public DownloadTask getTask(DownloadEntity entity) {
DownloadTask task = mExecutePool.getTask(entity.getDownloadUrl());
if (task == null) {
task = mCachePool.getTask(entity.getDownloadUrl());
}
@ -168,7 +168,7 @@ public class DownloadTaskQueue implements ITaskQueue {
}
@Override public void removeTask(DownloadEntity entity) {
Task task = mExecutePool.getTask(entity.getDownloadUrl());
DownloadTask task = mExecutePool.getTask(entity.getDownloadUrl());
if (task != null) {
Log.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败"));
}
@ -178,7 +178,7 @@ public class DownloadTaskQueue implements ITaskQueue {
}
}
@Override public Task getNextTask() {
@Override public DownloadTask getNextTask() {
return mCachePool.pollTask();
}

@ -15,9 +15,9 @@
*/
package com.arialyy.aria.core.queue;
package com.arialyy.aria.core.download.queue;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/8/16.
@ -27,28 +27,28 @@ public interface IDownloader {
/**
* 开始任务
*
* @param task {@link Task}
* @param task {@link DownloadTask}
*/
public void startTask(Task task);
public void startTask(DownloadTask task);
/**
* 停止任务
*
* @param task {@link Task}
* @param task {@link DownloadTask}
*/
public void stopTask(Task task);
public void stopTask(DownloadTask task);
/**
* 取消任务
*
* @param task {@link Task}
* @param task {@link DownloadTask}
*/
public void cancelTask(Task task);
public void cancelTask(DownloadTask task);
/**
* 重试下载
*
* @param task {@link Task}
* @param task {@link DownloadTask}
*/
public void reTryStart(Task task);
public void reTryStart(DownloadTask task);
}

@ -15,9 +15,9 @@
*/
package com.arialyy.aria.core.queue;
package com.arialyy.aria.core.download.queue;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/8/14.
@ -27,14 +27,14 @@ public interface IPool {
/**
* 将下载任务添加到任务池中
*/
public boolean putTask(Task task);
public boolean putTask(DownloadTask task);
/**
* 按照队列原则取出下载任务
*
* @return 返回null或者下载任务
*/
public Task pollTask();
public DownloadTask pollTask();
/**
* 通过下载链接获取下载任务当任务不为空时队列将删除该下载任务
@ -42,7 +42,7 @@ public interface IPool {
* @param downloadUrl 下载链接
* @return 返回null或者下载任务
*/
public Task getTask(String downloadUrl);
public DownloadTask getTask(String downloadUrl);
/**
* 删除任务池中的下载任务
@ -50,7 +50,7 @@ public interface IPool {
* @param task 下载任务
* @return true:移除成功
*/
public boolean removeTask(Task task);
public boolean removeTask(DownloadTask task);
/**
* 通过下载链接移除下载任务

@ -14,12 +14,11 @@
* limitations under the License.
*/
package com.arialyy.aria.core.queue;
package com.arialyy.aria.core.download.queue;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Created by lyy on 2016/8/16.
@ -49,17 +48,17 @@ public interface ITaskQueue extends IDownloader {
*
* @param entity 下载实体{@link DownloadTaskEntity}
* @param targetName 生成该任务的对象
* @return {@link Task}
* @return {@link DownloadTask}
*/
public Task createTask(String targetName, DownloadTaskEntity entity);
public DownloadTask createTask(String targetName, DownloadTaskEntity entity);
/**
* 通过下载链接从缓存池或任务池搜索下载任务如果缓存池或任务池都没有任务则创建新任务
*
* @param entity 下载实体{@link DownloadEntity}
* @return {@link Task}
* @return {@link DownloadTask}
*/
public Task getTask(DownloadEntity entity);
public DownloadTask getTask(DownloadEntity entity);
/**
* 通过下载链接删除任务
@ -73,5 +72,5 @@ public interface ITaskQueue extends IDownloader {
*
* @return 下载任务 or null
*/
public Task getNextTask();
public DownloadTask getNextTask();
}

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.arialyy.aria.core.queue.pool;
package com.arialyy.aria.core.download.queue.pool;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.queue.IPool;
import com.arialyy.aria.core.download.queue.IPool;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.task.Task;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
@ -36,8 +36,8 @@ public class CachePool implements IPool {
private static final int MAX_NUM = Integer.MAX_VALUE; //最大下载任务数
private static volatile CachePool INSTANCE = null;
private static final long TIME_OUT = 1000;
private Map<String, Task> mCacheArray;
private LinkedBlockingQueue<Task> mCacheQueue;
private Map<String, DownloadTask> mCacheArray;
private LinkedBlockingQueue<DownloadTask> mCacheQueue;
private CachePool() {
mCacheQueue = new LinkedBlockingQueue<>(MAX_NUM);
@ -53,7 +53,7 @@ public class CachePool implements IPool {
return INSTANCE;
}
@Override public boolean putTask(Task task) {
@Override public boolean putTask(DownloadTask task) {
synchronized (LOCK) {
if (task == null) {
Log.e(TAG, "下载任务不能为空!!");
@ -74,10 +74,10 @@ public class CachePool implements IPool {
}
}
@Override public Task pollTask() {
@Override public DownloadTask pollTask() {
synchronized (LOCK) {
try {
Task task = null;
DownloadTask task = null;
task = mCacheQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
if (task != null) {
String url = task.getDownloadEntity().getDownloadUrl();
@ -91,7 +91,7 @@ public class CachePool implements IPool {
return null;
}
@Override public Task getTask(String downloadUrl) {
@Override public DownloadTask getTask(String downloadUrl) {
synchronized (LOCK) {
if (TextUtils.isEmpty(downloadUrl)) {
Log.e(TAG, "请传入有效的下载链接");
@ -102,7 +102,7 @@ public class CachePool implements IPool {
}
}
@Override public boolean removeTask(Task task) {
@Override public boolean removeTask(DownloadTask task) {
synchronized (LOCK) {
if (task == null) {
Log.e(TAG, "任务不能为空");
@ -122,7 +122,7 @@ public class CachePool implements IPool {
return false;
}
String key = CommonUtil.keyToHashKey(downloadUrl);
Task task = mCacheArray.get(key);
DownloadTask task = mCacheArray.get(key);
mCacheArray.remove(key);
return mCacheQueue.remove(task);
}

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.arialyy.aria.core.queue.pool;
package com.arialyy.aria.core.download.queue.pool;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.queue.IPool;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.queue.IPool;
import com.arialyy.aria.util.Configuration;
import java.util.HashMap;
import java.util.Map;
@ -36,8 +36,8 @@ public class ExecutePool implements IPool {
private static final Object LOCK = new Object();
private static final long TIME_OUT = 1000;
private static volatile ExecutePool INSTANCE = null;
private ArrayBlockingQueue<Task> mExecuteQueue;
private Map<String, Task> mExecuteArray;
private ArrayBlockingQueue<DownloadTask> mExecuteQueue;
private Map<String, DownloadTask> mExecuteArray;
private int mSize;
private ExecutePool() {
@ -55,7 +55,7 @@ public class ExecutePool implements IPool {
return INSTANCE;
}
@Override public boolean putTask(Task task) {
@Override public boolean putTask(DownloadTask task) {
synchronized (LOCK) {
if (task == null) {
Log.e(TAG, "下载任务不能为空!!");
@ -85,8 +85,8 @@ public class ExecutePool implements IPool {
*/
public void setDownloadNum(int downloadNum) {
try {
ArrayBlockingQueue<Task> temp = new ArrayBlockingQueue<>(downloadNum);
Task task;
ArrayBlockingQueue<DownloadTask> temp = new ArrayBlockingQueue<>(downloadNum);
DownloadTask task;
while ((task = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS)) != null) {
temp.offer(task);
}
@ -103,7 +103,7 @@ public class ExecutePool implements IPool {
*
* @param newTask 新下载任务
*/
private boolean putNewTask(Task newTask) {
private boolean putNewTask(DownloadTask newTask) {
String url = newTask.getDownloadEntity().getDownloadUrl();
boolean s = mExecuteQueue.offer(newTask);
Log.w(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】"));
@ -119,7 +119,7 @@ public class ExecutePool implements IPool {
*/
private boolean pollFirstTask() {
try {
Task oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
DownloadTask oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
if (oldTask == null) {
Log.e(TAG, "移除任务失败");
return false;
@ -135,10 +135,10 @@ public class ExecutePool implements IPool {
return true;
}
@Override public Task pollTask() {
@Override public DownloadTask pollTask() {
synchronized (LOCK) {
try {
Task task = null;
DownloadTask task = null;
task = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
if (task != null) {
String url = task.getDownloadEntity().getDownloadUrl();
@ -152,7 +152,7 @@ public class ExecutePool implements IPool {
}
}
@Override public Task getTask(String downloadUrl) {
@Override public DownloadTask getTask(String downloadUrl) {
synchronized (LOCK) {
if (TextUtils.isEmpty(downloadUrl)) {
Log.e(TAG, "请传入有效的下载链接");
@ -163,7 +163,7 @@ public class ExecutePool implements IPool {
}
}
@Override public boolean removeTask(Task task) {
@Override public boolean removeTask(DownloadTask task) {
synchronized (LOCK) {
if (task == null) {
Log.e(TAG, "任务不能为空");
@ -183,7 +183,7 @@ public class ExecutePool implements IPool {
return false;
}
String key = CommonUtil.keyToHashKey(downloadUrl);
Task task = mExecuteArray.get(key);
DownloadTask task = mExecuteArray.get(key);
mExecuteArray.remove(key);
return mExecuteQueue.remove(task);
}

@ -14,15 +14,15 @@
* limitations under the License.
*/
package com.arialyy.aria.core.scheduler;
package com.arialyy.aria.core.download.scheduler;
import android.os.CountDownTimer;
import android.os.Message;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.queue.ITaskQueue;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.Configuration;
import java.util.Iterator;
import java.util.Map;
@ -108,7 +108,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
}
@Override public boolean handleMessage(Message msg) {
Task task = (Task) msg.obj;
DownloadTask task = (DownloadTask) msg.obj;
if (task == null) {
Log.e(TAG, "请传入下载任务");
return true;
@ -140,7 +140,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
*
* @param state 状态
*/
private void callback(int state, Task task) {
private void callback(int state, DownloadTask task) {
if (mSchedulerListeners.size() > 0) {
//if (!TextUtils.isEmpty(task.getTargetName())) {
// callback(state, task, mSchedulerListeners.get(task.getTargetName()));
@ -152,7 +152,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
}
}
private void callback(int state, Task task, OnSchedulerListener listener) {
private void callback(int state, DownloadTask task, OnSchedulerListener listener) {
if (listener != null) {
if (task == null) {
Log.e(TAG, "TASK 为null,回调失败");
@ -201,7 +201,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
@Override public void onFinish() {
if (entity.getFailNum() <= config.getReTryNum()) {
Task task = mQueue.getTask(entity);
DownloadTask task = mQueue.getTask(entity);
mQueue.reTryStart(task);
try {
Thread.sleep(config.getReTryInterval());
@ -222,7 +222,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
* @param entity 通过Handler传递的下载实体
*/
@Override public void startNextTask(DownloadEntity entity) {
Task newTask = mQueue.getNextTask();
DownloadTask newTask = mQueue.getNextTask();
if (newTask == null) {
Log.w(TAG, "没有下一任务");
return;

@ -14,10 +14,10 @@
* limitations under the License.
*/
package com.arialyy.aria.core.scheduler;
package com.arialyy.aria.core.download.scheduler;
import android.os.Handler;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.download.DownloadEntity;
/**
* Created by AriaLyy@outlook.com on 2016/11/2.

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.scheduler;
package com.arialyy.aria.core.download.scheduler;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
/**
* Target处理任务监听
@ -24,40 +24,40 @@ public interface OnSchedulerListener {
/**
* 任务预加载
*/
public void onTaskPre(Task task);
public void onTaskPre(DownloadTask task);
/**
* 任务恢复下载
*/
public void onTaskResume(Task task);
public void onTaskResume(DownloadTask task);
/**
* 任务开始
*/
public void onTaskStart(Task task);
public void onTaskStart(DownloadTask task);
/**
* 任务停止
*/
public void onTaskStop(Task task);
public void onTaskStop(DownloadTask task);
/**
* 任务取消
*/
public void onTaskCancel(Task task);
public void onTaskCancel(DownloadTask task);
/**
* 任务下载失败
*/
public void onTaskFail(Task task);
public void onTaskFail(DownloadTask task);
/**
* 任务完成
*/
public void onTaskComplete(Task task);
public void onTaskComplete(DownloadTask task);
/**
* 任务执行中
*/
public void onTaskRunning(Task task);
public void onTaskRunning(DownloadTask task);
}

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.util.CAConfiguration;
import com.arialyy.aria.util.SSLContextUtil;
import java.io.IOException;

@ -15,7 +15,7 @@
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
class DownloadListener implements IDownloadListener {

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
/**
* Created by lyy on 2017/1/18.

@ -14,17 +14,17 @@
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.download.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.Configuration;
@ -34,8 +34,8 @@ import java.lang.ref.WeakReference;
* Created by lyy on 2016/8/11.
* 下载任务类
*/
public class Task {
public static final String TAG = "Task";
public class DownloadTask {
public static final String TAG = "DownloadTask";
/**
* 产生该任务对象的hash码
*/
@ -47,7 +47,7 @@ public class Task {
private Context mContext;
private IDownloadUtil mUtil;
private Task(Context context, DownloadTaskEntity taskEntity, Handler outHandler) {
private DownloadTask(Context context, DownloadTaskEntity taskEntity, Handler outHandler) {
mContext = context.getApplicationContext();
mTaskEntity = taskEntity;
mEntity = taskEntity.downloadEntity;
@ -199,8 +199,8 @@ public class Task {
return this;
}
public Task build() {
Task task = new Task(context, taskEntity, outHandler);
public DownloadTask build() {
DownloadTask task = new DownloadTask(context, taskEntity, outHandler);
task.setTargetName(targetName);
taskEntity.downloadEntity.save();
return task;
@ -212,7 +212,7 @@ public class Task {
*/
private static class DListener extends DownloadListener {
WeakReference<Handler> outHandler;
WeakReference<Task> wTask;
WeakReference<DownloadTask> wTask;
Context context;
Intent sendIntent;
long INTERVAL = 1024 * 10; //10k大小的间隔
@ -221,9 +221,9 @@ public class Task {
long INTERVAL_TIME = 1000; //1m更新周期
boolean isFirst = true;
DownloadEntity downloadEntity;
Task task;
DownloadTask task;
DListener(Context context, Task task, Handler outHandler) {
DListener(Context context, DownloadTask task, Handler outHandler) {
this.context = context;
this.outHandler = new WeakReference<>(outHandler);
this.wTask = new WeakReference<>(task);

@ -14,30 +14,30 @@
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
import android.content.Context;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.scheduler.IDownloadSchedulers;
/**
* Created by lyy on 2016/8/18.
* 任务工厂
*/
public class TaskFactory {
private static final String TAG = "TaskFactory";
public class DownloadTaskFactory {
private static final String TAG = "DownloadTaskFactory";
private static final Object LOCK = new Object();
private static volatile TaskFactory INSTANCE = null;
private static volatile DownloadTaskFactory INSTANCE = null;
private TaskFactory() {
private DownloadTaskFactory() {
}
public static TaskFactory getInstance() {
public static DownloadTaskFactory getInstance() {
if (INSTANCE == null) {
synchronized (LOCK) {
INSTANCE = new TaskFactory();
INSTANCE = new DownloadTaskFactory();
}
}
return INSTANCE;
@ -49,7 +49,7 @@ public class TaskFactory {
* @param entity 下载任务实体{@link DownloadTaskEntity}
* @param schedulers {@link IDownloadSchedulers}
*/
public Task createTask(Context context, DownloadTaskEntity entity,
public DownloadTask createTask(Context context, DownloadTaskEntity entity,
IDownloadSchedulers schedulers) {
return createTask("", context, entity, schedulers);
}
@ -58,9 +58,9 @@ public class TaskFactory {
* @param entity 下载任务实体{@link DownloadTaskEntity}
* @param schedulers {@link IDownloadSchedulers}
*/
public Task createTask(String targetName, Context context, DownloadTaskEntity entity,
public DownloadTask createTask(String targetName, Context context, DownloadTaskEntity entity,
IDownloadSchedulers schedulers) {
Task.Builder builder = new Task.Builder(targetName, context, entity);
DownloadTask.Builder builder = new DownloadTask.Builder(targetName, context, entity);
builder.setOutHandler(schedulers);
return builder.build();
}

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
import android.content.Context;
import android.util.Log;
import android.util.SparseArray;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.io.File;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
/**
* 下载监听

@ -15,13 +15,13 @@
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
/**
* Created by AriaLyy@outlook.com on 2016/10/31.
* 抽象的下载接口
*/
public interface IDownloadUtil {
interface IDownloadUtil {
/**
* 获取当前下载位置

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.task;
package com.arialyy.aria.core.download.task;
import android.util.Log;
import com.arialyy.aria.util.CommonUtil;

@ -0,0 +1,12 @@
package com.arialyy.aria.core.inf;
/**
* Created by Aria.Lao on 2017/2/9.
*/
public interface ICmd {
/**
* 执行命令
*/
public abstract void executeCmd();
}

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.inf;
/**
* Created by Aria.Lao on 2017/2/6.
*/
interface IReceiver {
public interface IReceiver {
/**
* Receiver 销毁
*/

@ -0,0 +1,11 @@
package com.arialyy.aria.core.upload;
/**
* Created by Aria.Lao on 2017/2/9.
* 上传监听
*/
public interface IUploadListener {
public void onFail();
}

@ -0,0 +1,150 @@
package com.arialyy.aria.core.upload;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class MultipartUtility {
private final String boundary;
private static final String LINE_FEED = "\r\n";
private HttpURLConnection httpConn;
private String charset;
private OutputStream outputStream;
private PrintWriter writer;
/**
* This constructor initializes a new HTTP POST request with content type
* is set to multipart/form-data
*
* @param requestURL
* @param charset
* @throws IOException
*/
public MultipartUtility(String requestURL, String charset)
throws IOException {
this.charset = charset;
// creates a unique boundary based on time stamp
boundary = "===" + System.currentTimeMillis() + "===";
URL url = new URL(requestURL);
Log.e("URL", "URL : " + requestURL.toString());
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setUseCaches(false);
httpConn.setDoOutput(true); // indicates POST method
httpConn.setDoInput(true);
httpConn.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + boundary);
httpConn.setRequestProperty("User-Agent", "CodeJava Agent");
httpConn.setRequestProperty("Test", "Bonjour");
outputStream = httpConn.getOutputStream();
writer = new PrintWriter(new OutputStreamWriter(outputStream, charset),
true);
}
/**
* Adds a form field to the request
*
* @param name field name
* @param value field value
*/
public void addFormField(String name, String value) {
writer.append("--" + boundary).append(LINE_FEED);
writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
.append(LINE_FEED);
writer.append("Content-Type: text/plain; charset=" + charset).append(
LINE_FEED);
writer.append(LINE_FEED);
writer.append(value).append(LINE_FEED);
writer.flush();
}
/**
* Adds a upload file section to the request
*
* @param fieldName name attribute in <input type="file" name="..." />
* @param uploadFile a File to be uploaded
* @throws IOException
*/
public void addFilePart(String fieldName, File uploadFile)
throws IOException {
String fileName = uploadFile.getName();
writer.append("--" + boundary).append(LINE_FEED);
writer.append(
"Content-Disposition: form-data; name=\"" + fieldName
+ "\"; filename=\"" + fileName + "\"")
.append(LINE_FEED);
writer.append(
"Content-Type: "
+ URLConnection.guessContentTypeFromName(fileName))
.append(LINE_FEED);
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
writer.append(LINE_FEED);
writer.flush();
FileInputStream inputStream = new FileInputStream(uploadFile);
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
inputStream.close();
writer.append(LINE_FEED);
writer.flush();
}
/**
* Adds a header field to the request.
*
* @param name - name of the header field
* @param value - value of the header field
*/
public void addHeaderField(String name, String value) {
writer.append(name + ": " + value).append(LINE_FEED);
writer.flush();
}
/**
* Completes the request and receives response from the server.
*
* @return a list of Strings as response in case the server returned
* status OK, otherwise an exception is thrown.
* @throws IOException
*/
public String finish() throws IOException {
StringBuffer response = new StringBuffer();
writer.append(LINE_FEED).flush();
writer.append("--" + boundary + "--").append(LINE_FEED);
writer.close();
// checks server's status code first
int status = httpConn.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
httpConn.disconnect();
} else {
throw new IOException("Server returned non-OK status: " + status);
}
return response.toString();
}
}

@ -0,0 +1,30 @@
package com.arialyy.aria.core.upload;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.orm.DbEntity;
/**
* Created by Aria.Lao on 2017/2/9.
* 上传文件实体
*/
public class UploadEntity {
private String filePath; //文件路径
private String fileName; //文件名
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
}

@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.upload;
import com.arialyy.aria.core.inf.IReceiver;
/**
* Created by Aria.Lao on 2017/2/6.

@ -0,0 +1,22 @@
package com.arialyy.aria.core.upload;
import com.arialyy.aria.core.RequestEnum;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Aria.Lao on 2017/2/9.
*/
public class UploadTaskEntity {
public UploadEntity uploadEntity;
public RequestEnum requestEnum = RequestEnum.GET;
public String uploadUrl; //上传路径
public String uploadKey; //文件上传需要的key
public String contentType = "multipart/form-data"; //上传的文件类型
public Map<String, String> headers = new HashMap<>();
public UploadTaskEntity(UploadEntity downloadEntity) {
this.uploadEntity = downloadEntity;
}
}

@ -0,0 +1,122 @@
package com.arialyy.aria.core.upload;
import android.util.Log;
import com.arialyy.aria.util.CheckUtil;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* Created by Aria.Lao on 2017/2/9.
* 上传工具
*/
public class UploadUtil implements Runnable {
private static final String TAG = "UploadUtil";
private UploadEntity mUploadEntity;
private UploadTaskEntity mTaskEntity;
private IUploadListener mListener;
public UploadUtil(UploadTaskEntity taskEntity, IUploadListener listener) {
mTaskEntity = taskEntity;
CheckUtil.checkUploadEntity(taskEntity.uploadEntity);
mUploadEntity = taskEntity.uploadEntity;
mListener = listener;
}
public void start() {
new Thread(this).start();
}
@Override public void run() {
File file = new File(mUploadEntity.getFilePath());
if (!file.exists()) {
Log.e(TAG, "【" + mUploadEntity.getFilePath() + "】,文件不存在。");
mListener.onFail();
return;
}
String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
String PREFIX = "--", LINE_END = "\r\n";
String CONTENT_TYPE = "multipart/form-data"; // 内容类型
try {
HttpURLConnection conn = (HttpURLConnection) new URL(mTaskEntity.uploadUrl).openConnection();
conn.setReadTimeout(5000);
conn.setConnectTimeout(5000);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Charset", "utf-8"); // 设置编码
conn.setRequestProperty("connection", "keep-alive");
//conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY);
conn.setRequestProperty("Content-Type", mTaskEntity.contentType + ";boundary=" + BOUNDARY);
Set<String> keys = mTaskEntity.headers.keySet();
for (String key : keys) {
conn.setRequestProperty(key, mTaskEntity.headers.get(key));
}
OutputStream outputSteam = conn.getOutputStream();
DataOutputStream dos = new DataOutputStream(outputSteam);
StringBuilder sb = new StringBuilder();
sb.append(PREFIX);
sb.append(BOUNDARY);
sb.append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"")
.append(mTaskEntity.uploadUrl)
.append("\"; filename=\"")
.append(file.getName())
.append("\"")
.append(LINE_END);
sb.append("Content-Type:")
.append(mTaskEntity.contentType)
.append("; charset=utf-8")
.append(LINE_END);
sb.append(LINE_END);
dos.write(sb.toString().getBytes());
InputStream is = new FileInputStream(file);
byte[] bytes = new byte[1024];
int len = 0;
while ((len = is.read(bytes)) != -1) {
dos.write(bytes, 0, len);
}
is.close();
dos.write(LINE_END.getBytes());
byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes();
dos.write(end_data);
dos.flush();
dos.close();
int res = conn.getResponseCode();
if (res == 200) {
BufferedInputStream inputStream = new BufferedInputStream(conn.getInputStream());
byte[] buf = new byte[1024];
StringBuilder stringBuilder = new StringBuilder();
while (inputStream.read(buf) > 0) {
stringBuilder.append(new String(buf, 0, buf.length));
}
String data = stringBuilder.toString();
Log.d(TAG, data);
//L.j(data);
//absResponse.onResponse(data);
} else {
//absResponse.onError("error");
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -18,7 +18,8 @@ package com.arialyy.aria.util;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.exception.FileException;
import java.io.File;
import java.util.regex.Matcher;
@ -73,21 +74,32 @@ public class CheckUtil {
if (TextUtils.isEmpty(downloadUrl)) throw new IllegalArgumentException("下载链接不能为null");
}
/**
* 检查上传实体是否合法
*/
public static void checkUploadEntity(UploadEntity entity) {
if (entity == null) {
throw new NullPointerException("上传实体不能为空");
}
if (TextUtils.isEmpty(entity.getFilePath())) {
throw new IllegalArgumentException("上传文件路径不能为空");
} else if (TextUtils.isEmpty(entity.getFileName())) {
throw new IllegalArgumentException("上传文件名不能为空");
}
}
/**
* 检测下载实体是否合法
*
* @param entity 下载实体
* @return 合法(true)
*/
public static boolean checkDownloadEntity(DownloadEntity entity) {
public static void checkDownloadEntity(DownloadEntity entity) {
if (entity == null) {
Log.w(TAG, "下载实体不能为空");
return false;
throw new NullPointerException("下载实体不能为空");
} else if (TextUtils.isEmpty(entity.getDownloadUrl())) {
Log.w(TAG, "下载链接不能为空");
return false;
throw new IllegalArgumentException("下载链接不能为空");
} else if (TextUtils.isEmpty(entity.getFileName())) {
//Log.w(TAG, "文件名不能为空");
throw new FileException("文件名不能为null");
} else if (TextUtils.isEmpty(entity.getDownloadPath())) {
throw new FileException("文件保存路径不能为null");
@ -102,6 +114,5 @@ public class CheckUtil {
dPath += fileName;
entity.setDownloadPath(dPath);
}
return true;
}
}

@ -21,10 +21,9 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;
import com.arialyy.aria.core.DownloadTaskEntity;
import com.arialyy.aria.core.command.download.CmdFactory;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.command.download.IDownloadCmd;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.download.command.CmdFactory;
import com.arialyy.aria.core.download.command.IDownloadCmd;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

@ -14,8 +14,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".activity.SingleTaskActivity"-->
<!--android:name=".MainActivity"-->
<activity
android:name=".MainActivity"
android:name=".upload"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -7,10 +7,10 @@ import android.widget.Button;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;
import com.arialyy.aria.core.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsDialog;
import com.arialyy.simple.R;
@ -86,26 +86,26 @@ public class DownloadDialog extends AbsDialog {
private class MyDialogDownloadCallback extends Aria.SimpleSchedulerListener {
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
super.onTaskPre(task);
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
setBtState(false);
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
setBtState(true);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
super.onTaskCancel(task);
setBtState(true);
mPb.setProgress(0);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
long current = task.getCurrentProgress();
long len = task.getFileSize();

@ -7,10 +7,10 @@ import android.widget.Button;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;
import com.arialyy.aria.core.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsFragment;
import com.arialyy.simple.R;
@ -90,26 +90,26 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
private class MyDialogDownloadCallback extends Aria.SimpleSchedulerListener {
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
super.onTaskPre(task);
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
setBtState(false);
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
setBtState(true);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
super.onTaskCancel(task);
setBtState(true);
mPb.setProgress(0);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
long current = task.getCurrentProgress();
long len = task.getFileSize();

@ -23,7 +23,7 @@ import android.content.IntentFilter;
import android.os.Environment;
import android.os.Handler;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.AndroidUtils;
import com.arialyy.frame.util.StringUtil;

@ -5,7 +5,7 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import butterknife.Bind;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
@ -40,45 +40,45 @@ public class DownloadActivity extends BaseActivity<ActivityDownloadBinding> {
}
private class MySchedulerListener extends Aria.SimpleSchedulerListener {
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
super.onTaskPre(task);
L.d(TAG, "download pre");
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskStart(Task task) {
@Override public void onTaskStart(DownloadTask task) {
super.onTaskStart(task);
L.d(TAG, "download start");
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskResume(Task task) {
@Override public void onTaskResume(DownloadTask task) {
super.onTaskResume(task);
L.d(TAG, "download resume");
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
mAdapter.setProgress(task.getDownloadEntity());
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
super.onTaskCancel(task);
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskComplete(Task task) {
@Override public void onTaskComplete(DownloadTask task) {
super.onTaskComplete(task);
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskFail(Task task) {
@Override public void onTaskFail(DownloadTask task) {
super.onTaskFail(task);
L.d(TAG, "download fail");
}

@ -25,7 +25,7 @@ import butterknife.Bind;
import com.arialyy.absadapter.common.AbsHolder;
import com.arialyy.absadapter.recycler_view.AbsRVAdapter;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.simple.R;
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber;

@ -24,7 +24,7 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import butterknife.Bind;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMultiBinding;
@ -89,26 +89,26 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
private class DownloadListener extends Aria.SimpleSchedulerListener {
@Override public void onTaskStart(Task task) {
@Override public void onTaskStart(DownloadTask task) {
super.onTaskStart(task);
mAdapter.updateBtState(task.getDownloadUrl(), false);
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
}
@Override public void onTaskResume(Task task) {
@Override public void onTaskResume(DownloadTask task) {
super.onTaskResume(task);
mAdapter.updateBtState(task.getDownloadUrl(), false);
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
mAdapter.updateBtState(task.getDownloadUrl(), true);
}
@Override public void onTaskComplete(Task task) {
@Override public void onTaskComplete(DownloadTask task) {
super.onTaskComplete(task);
mAdapter.updateBtState(task.getDownloadUrl(), true);
}

@ -5,7 +5,7 @@ import android.content.Context;
import android.os.Environment;
import android.support.v4.app.NotificationCompat;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.simple.R;
/**
@ -59,19 +59,19 @@ public class SimpleNotification {
mManager = manager;
}
@Override public void onTaskStart(Task task) {
@Override public void onTaskStart(DownloadTask task) {
super.onTaskStart(task);
}
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
super.onTaskPre(task);
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
long len = task.getFileSize();
int p = (int) (task.getCurrentProgress() * 100 / len);
@ -81,7 +81,7 @@ public class SimpleNotification {
}
}
@Override public void onTaskComplete(Task task) {
@Override public void onTaskComplete(DownloadTask task) {
super.onTaskComplete(task);
if (mBuilder != null) {
mBuilder.setProgress(100, 100, false);
@ -89,7 +89,7 @@ public class SimpleNotification {
}
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
super.onTaskCancel(task);
}
}

@ -9,10 +9,10 @@ import android.widget.Button;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;
import com.arialyy.aria.core.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsPopupWindow;
import com.arialyy.simple.R;
@ -88,26 +88,26 @@ public class DownloadPopupWindow extends AbsPopupWindow {
private class MyDialogDownloadCallback extends Aria.SimpleSchedulerListener {
@Override public void onTaskPre(Task task) {
@Override public void onTaskPre(DownloadTask task) {
super.onTaskPre(task);
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
setBtState(false);
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
super.onTaskStop(task);
setBtState(true);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
super.onTaskCancel(task);
setBtState(true);
mPb.setProgress(0);
mSpeed.setText("0.0kb/s");
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
super.onTaskRunning(task);
long current = task.getCurrentProgress();
long len = task.getFileSize();

@ -30,10 +30,10 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.Bind;
import com.arialyy.aria.core.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;
@ -76,7 +76,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
super.handleMessage(msg);
switch (msg.what) {
case DOWNLOAD_RUNNING:
Task task = (Task) msg.obj;
DownloadTask task = (DownloadTask) msg.obj;
long current = task.getCurrentProgress();
long len = task.getFileSize();
if (len == 0) {
@ -208,33 +208,33 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
}
private class MySchedulerListener extends Aria.SimpleSchedulerListener {
@Override public void onTaskStart(Task task) {
@Override public void onTaskStart(DownloadTask task) {
mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize())
.sendToTarget();
}
@Override public void onTaskResume(Task task) {
@Override public void onTaskResume(DownloadTask task) {
super.onTaskResume(task);
mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getFileSize()).sendToTarget();
}
@Override public void onTaskStop(Task task) {
@Override public void onTaskStop(DownloadTask task) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP);
}
@Override public void onTaskCancel(Task task) {
@Override public void onTaskCancel(DownloadTask task) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL);
}
@Override public void onTaskFail(Task task) {
@Override public void onTaskFail(DownloadTask task) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_FAILE);
}
@Override public void onTaskComplete(Task task) {
@Override public void onTaskComplete(DownloadTask task) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_COMPLETE);
}
@Override public void onTaskRunning(Task task) {
@Override public void onTaskRunning(DownloadTask task) {
mUpdateHandler.obtainMessage(DOWNLOAD_RUNNING, task).sendToTarget();
}
}

@ -0,0 +1,36 @@
package com.arialyy.simple;
import android.view.View;
import com.arialyy.aria.core.upload.IUploadListener;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.core.upload.UploadUtil;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityUploadBinding;
/**
* Created by Aria.Lao on 2017/2/9.
*/
public class upload extends BaseActivity<ActivityUploadBinding>{
@Override protected int setLayoutId() {
return R.layout.activity_upload;
}
public void onClick(View view){
UploadEntity entity = new UploadEntity();
entity.setFilePath("/sdcard/Download/test.pdf");
entity.setFileName("test.pdf");
UploadTaskEntity taskEntity = new UploadTaskEntity(entity);
taskEntity.uploadUrl = "http://172.21.1.160:8080/upload";
taskEntity.uploadKey = "file";
UploadUtil util = new UploadUtil(taskEntity, new IUploadListener() {
@Override public void onFail() {
}
});
util.start();
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/layout_bar"/>
<Button
android:id="@+id/single_task"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="上传"
style="?buttonBarButtonStyle"
/>
</LinearLayout>
</layout>
Loading…
Cancel
Save