From 32e7c7f235c89ea09610a4a095906e67406dee5f Mon Sep 17 00:00:00 2001
From: AriaLyy <511455842@qq.com>
Date: Mon, 2 Jan 2017 15:29:58 +0800
Subject: [PATCH] =?UTF-8?q?bug=20=E4=BF=AE=E5=A4=8D=EF=BC=8C=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/arialyy/aria/core/AMReceiver.java | 13 ++++-
.../java/com/arialyy/aria/core/AMTarget.java | 38 +++++++++----
.../com/arialyy/aria/core/AriaManager.java | 16 ++++--
.../arialyy/aria/core/task/DownloadUtil.java | 1 +
.../java/com/arialyy/aria/core/task/Task.java | 26 +++++----
.../java/com/arialyy/aria/orm/DbEntity.java | 36 ++++++++----
.../java/com/arialyy/aria/orm/DbUtil.java | 51 +++++++++++++++--
.../java/com/arialyy/aria/orm/SqlHelper.java | 2 +-
.../java/com/arialyy/aria/util/CheckUtil.java | 37 +++++++++++++
.../simple/activity/MultiTaskActivity.java | 2 +-
.../simple/activity/SingleTaskActivity.java | 55 ++++++++++---------
.../simple/adapter/DownloadAdapter.java | 1 +
app/src/main/res/layout/content_single.xml | 8 +++
13 files changed, 217 insertions(+), 69 deletions(-)
diff --git a/Aria/src/main/java/com/arialyy/aria/core/AMReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/AMReceiver.java
index c08ff3eb..23cccb3d 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/AMReceiver.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/AMReceiver.java
@@ -20,6 +20,7 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.scheduler.OnSchedulerListener;
+import com.arialyy.aria.util.CheckUtil;
/**
* Created by lyy on 2016/12/5.
@@ -30,6 +31,9 @@ public class AMReceiver {
OnSchedulerListener listener;
DownloadEntity entity;
+ /**
+ * {@link #load(String)},请使用该方法
+ */
@Deprecated public AMTarget load(DownloadEntity entity) {
this.entity = entity;
return new AMTarget(this);
@@ -39,10 +43,13 @@ public class AMReceiver {
* 读取下载链接
*/
public AMTarget load(@NonNull String downloadUrl) {
- if (TextUtils.isEmpty(downloadUrl)) {
- throw new IllegalArgumentException("下载链接不能为null");
+ CheckUtil.checkDownloadUrl(downloadUrl);
+ if (entity == null) {
+ entity = DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ }
+ if (entity == null) {
+ entity = new DownloadEntity();
}
- entity = new DownloadEntity();
entity.setDownloadUrl(downloadUrl);
return new AMTarget(this);
}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/AMTarget.java b/Aria/src/main/java/com/arialyy/aria/core/AMTarget.java
index 54f18861..ce6aecd9 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/AMTarget.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/AMTarget.java
@@ -19,6 +19,7 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.arialyy.aria.core.command.CmdFactory;
import com.arialyy.aria.core.command.IDownloadCmd;
+import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;
import java.util.List;
@@ -56,6 +57,33 @@ public class AMTarget {
return this;
}
+ /**
+ * 获取下载文件大小
+ */
+ public long getFileSize() {
+ DownloadEntity entity = getDownloadEntity(mReceiver.entity.getDownloadUrl());
+ if (entity == null) {
+ throw new NullPointerException("下载管理器中没有改任务");
+ }
+ return entity.getFileSize();
+ }
+
+ /**
+ * 获取当前下载进度,如果下載实体存在,则返回当前进度
+ */
+ public long getCurrentProgress() {
+ DownloadEntity entity = getDownloadEntity(mReceiver.entity.getDownloadUrl());
+ if (entity == null) {
+ throw new NullPointerException("下载管理器中没有改任务");
+ }
+ return entity.getCurrentProgress();
+ }
+
+ private DownloadEntity getDownloadEntity(String downloadUrl) {
+ CheckUtil.checkDownloadUrl(downloadUrl);
+ return DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ }
+
/**
* 添加任务
*/
@@ -117,14 +145,4 @@ public class AMTarget {
cancel();
start();
}
-
- //static class Build {
- // DownloadEntity entity;
- //
- // Build(DownloadEntity entity) {
- // this.entity = entity;
- // }
- //
- //
- //}
}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
index eb72a04c..a48e93c8 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
@@ -29,9 +29,11 @@ import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.command.CmdFactory;
+import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.command.IDownloadCmd;
import com.arialyy.aria.util.Configuration;
+import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
@@ -81,11 +83,15 @@ import java.util.Set;
* 通过下载链接获取下载实体
*/
public DownloadEntity getDownloadEntity(String downloadUrl) {
- if (TextUtils.isEmpty(downloadUrl)) {
- throw new IllegalArgumentException("下载链接不能为null");
- }
- return DownloadEntity.findData(DownloadEntity.class, new String[] { "downloadUrl" },
- new String[] { downloadUrl });
+ CheckUtil.checkDownloadUrl(downloadUrl);
+ return DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ }
+
+ /**
+ * 下载任务是否存在
+ */
+ public boolean taskExists(String downloadUrl) {
+ return DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl) != null;
}
/**
diff --git a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
index 481d9b09..97c845c9 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
@@ -524,6 +524,7 @@ final class DownloadUtil implements IDownloadUtil, Runnable {
*/
private void progress(long len) {
synchronized (LOCK) {
+ currentLocation += len;
mCurrentLocation += len;
mListener.onProgress(mCurrentLocation);
}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/task/Task.java b/Aria/src/main/java/com/arialyy/aria/core/task/Task.java
index 5420362b..6f7ec758 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/task/Task.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/Task.java
@@ -44,7 +44,6 @@ public class Task {
private Handler mOutHandler;
private Context mContext;
private IDownloadUtil mUtil;
- private long mSpeed;
private Task(Context context, DownloadEntity entity, Handler outHandler) {
mContext = context.getApplicationContext();
@@ -62,7 +61,21 @@ public class Task {
* 获取下载速度
*/
public long getSpeed() {
- return mSpeed;
+ return mEntity.getSpeed();
+ }
+
+ /**
+ * 获取文件大小
+ */
+ public long getFileSize(){
+ return mEntity.getFileSize();
+ }
+
+ /**
+ * 获取当前下载进度
+ */
+ public long getCurrentProgress(){
+ return mEntity.getCurrentProgress();
}
/**
@@ -111,13 +124,6 @@ public class Task {
}
}
- /**
- * 获取下载工具
- */
- public IDownloadUtil getDownloadUtil() {
- return mUtil;
- }
-
/**
* 任务下载状态
*/
@@ -221,7 +227,7 @@ public class Task {
this.context = context;
this.outHandler = new WeakReference<>(outHandler);
this.wTask = new WeakReference<>(task);
- task = wTask.get();
+ this.task = wTask.get();
this.downloadEntity = this.task.getDownloadEntity();
sendIntent = CommonUtil.createIntent(context.getPackageName(), Aria.ACTION_RUNNING);
sendIntent.putExtra(Aria.ENTITY, downloadEntity);
diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
index 1d24fd33..c1dfbe08 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
@@ -55,24 +55,28 @@ public class DbEntity {
/**
* 查询一组数据
+ *
+ * DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ *
*
* @return 没有数据返回null
*/
- public static List findDatas(Class clazz, @NonNull String[] wheres,
- @NonNull String[] values) {
+ public static List findDatas(Class clazz, String... expression) {
DbUtil util = DbUtil.getInstance();
- return util.findData(clazz, wheres, values);
+ return util.findData(clazz, expression);
}
/**
* 查询一行数据
+ *
+ * DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ *
*
* @return 没有数据返回null
*/
- public static T findData(Class clazz, @NonNull String[] wheres,
- @NonNull String[] values) {
+ public static T findData(Class clazz, String... expression) {
DbUtil util = DbUtil.getInstance();
- List datas = util.findData(clazz, wheres, values);
+ List datas = util.findData(clazz, expression);
return datas == null ? null : datas.size() > 0 ? datas.get(0) : null;
}
@@ -94,14 +98,19 @@ public class DbEntity {
* 删除当前数据
*/
public void deleteData() {
- mUtil.delData(getClass(), new Object[] { "rowid" }, new Object[] { rowID });
+ //mUtil.delData(getClass(), new Object[] { "rowid" }, new Object[] { rowID });
+ deleteData(getClass(), "rowid=?", rowID + "");
}
/**
* 根据条件删除数据
+ *
+ * DownloadEntity.deleteData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
+ *
*/
- public void deleteData(@NonNull Object[] wheres, @NonNull Object[] values) {
- mUtil.delData(getClass(), wheres, values);
+ public static void deleteData(Class clazz, String... expression) {
+ DbUtil util = DbUtil.getInstance();
+ util.delData(clazz, expression);
}
/**
@@ -128,7 +137,7 @@ public class DbEntity {
* 查找数据在表中是否存在
*/
private boolean thisIsExist() {
- return findData(getClass(), new String[] { "rowid" }, new String[] { rowID + "" }) != null;
+ return findData(getClass(), "rowid=?", rowID + "") != null;
}
/**
@@ -139,6 +148,13 @@ public class DbEntity {
updateRowID();
}
+ private T findData(Class clazz, @NonNull String[] wheres,
+ @NonNull String[] values) {
+ DbUtil util = DbUtil.getInstance();
+ List list = util.findData(clazz, wheres, values);
+ return list == null ? null : list.get(0);
+ }
+
private void updateRowID() {
try {
Field[] fields = CommonUtil.getFields(getClass());
diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java b/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
index c83b9fb2..4f6fe2b1 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;
import android.util.Log;
+import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -76,8 +77,8 @@ public class DbUtil {
/**
* 删除某条数据
*/
- synchronized void delData(Class clazz, @NonNull Object[] wheres,
- @NonNull Object[] values) {
+ @Deprecated private synchronized void delData(Class clazz,
+ @NonNull Object[] wheres, @NonNull Object[] values) {
mDb = mHelper.getWritableDatabase();
if (wheres.length <= 0 || values.length <= 0) {
Log.e(TAG, "输入删除条件");
@@ -99,6 +100,25 @@ public class DbUtil {
close();
}
+ /**
+ * 删除某条数据
+ */
+ synchronized void delData(Class clazz, String... expression) {
+ CheckUtil.checkSqlExpression(expression);
+ mDb = mHelper.getWritableDatabase();
+ String sql = "DELETE FROM " + CommonUtil.getClassName(clazz) + " WHERE " + expression[0] + " ";
+ sql = sql.replace("?", "%s");
+ Object[] params = new String[expression.length - 1];
+ for (int i = 0, len = params.length; i < len; i++) {
+ params[i] = "'" + expression[i + 1] + "'";
+ }
+ sql = String.format(sql, params);
+ Log.d(TAG, sql);
+ print(DEL_DATA, sql);
+ mDb.execSQL(sql);
+ close();
+ }
+
/**
* 修改某行数据
*/
@@ -151,8 +171,31 @@ public class DbUtil {
/**
* 条件查寻数据
*/
- synchronized List findData(Class clazz, @NonNull String[] wheres,
- @NonNull String[] values) {
+ synchronized List findData(Class clazz, String... expression) {
+ if (!tableExists(clazz)) {
+ createTable(clazz);
+ }
+ mDb = mHelper.getReadableDatabase();
+ CheckUtil.checkSqlExpression(expression);
+ String sql =
+ "SELECT rowid, * FROM " + CommonUtil.getClassName(clazz) + " WHERE " + expression[0] + " ";
+ sql = sql.replace("?", "%s");
+ Object[] params = new String[expression.length - 1];
+ for (int i = 0, len = params.length; i < len; i++) {
+ params[i] = "'" + expression[i + 1] + "'";
+ }
+ sql = String.format(sql, params);
+ Log.d(TAG, sql);
+ print(FIND_DATA, sql);
+ Cursor cursor = mDb.rawQuery(sql, null);
+ return cursor.getCount() > 0 ? newInstanceEntity(clazz, cursor) : null;
+ }
+
+ /**
+ * 条件查寻数据
+ */
+ @Deprecated synchronized List findData(Class clazz,
+ @NonNull String[] wheres, @NonNull String[] values) {
if (!tableExists(clazz)) {
createTable(clazz);
}
diff --git a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
index a7b6c669..4ab30b02 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
@@ -26,7 +26,7 @@ import android.text.TextUtils;
* Created by lyy on 2015/11/2.
* sql帮助类
*/
-public class SqlHelper extends SQLiteOpenHelper {
+final class SqlHelper extends SQLiteOpenHelper {
protected static String DB_NAME;
protected static int VERSION = -1;
diff --git a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
index 26ad8fe3..7cffe259 100644
--- a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
@@ -20,6 +20,8 @@ import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.DownloadEntity;
import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Created by Lyy on 2016/9/23.
@@ -28,6 +30,41 @@ import java.io.File;
public class CheckUtil {
private static final String TAG = "CheckUtil";
+ /**
+ * 检查sql的expression是否合法
+ */
+ public static void checkSqlExpression(String... expression) {
+ if (expression.length == 0) {
+ throw new IllegalArgumentException("sql语句表达式不能为null");
+ }
+ if (expression.length == 1) {
+ throw new IllegalArgumentException("表达式需要写入参数");
+ }
+ String where = expression[0];
+ if (!where.contains("?")) {
+ throw new IllegalArgumentException("请在where语句的'='后编写?");
+ }
+ Pattern pattern = Pattern.compile("\\?");
+ Matcher matcher = pattern.matcher(where);
+ int count = 0;
+ while (matcher.find()) {
+ count++;
+ }
+ if (count < expression.length - 1){
+ throw new IllegalArgumentException("条件语句的?个数不能小于参数个数");
+ }
+ if (count > expression.length - 1){
+ throw new IllegalArgumentException("条件语句的?个数不能大于参数个数");
+ }
+ }
+
+ /**
+ * 检测下载链接是否为null
+ */
+ public static void checkDownloadUrl(String downloadUrl) {
+ if (TextUtils.isEmpty(downloadUrl)) throw new IllegalArgumentException("下载链接不能为null");
+ }
+
/**
* 检测下载实体是否合法
*
diff --git a/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java b/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java
index 4e61682a..5556eafa 100644
--- a/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java
@@ -132,7 +132,7 @@ public class MultiTaskActivity extends BaseActivity {
}
}
- private class MySchedulerListener extends AMTarget.SimpleSchedulerListener{
+ private class MySchedulerListener extends Aria.SimpleSchedulerListener{
@Override public void onTaskPre(Task task) {
super.onTaskPre(task);
L.d(TAG, "download pre");
diff --git a/app/src/main/java/com/arialyy/simple/activity/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/activity/SingleTaskActivity.java
index 29c6c1dd..7c259352 100644
--- a/app/src/main/java/com/arialyy/simple/activity/SingleTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/activity/SingleTaskActivity.java
@@ -19,6 +19,8 @@ package com.arialyy.simple.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -26,6 +28,7 @@ import android.os.Message;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.Bind;
@@ -53,6 +56,8 @@ public class SingleTaskActivity extends BaseActivity {
public static final int DOWNLOAD_RUNNING = 0x07;
private static final String DOWNLOAD_URL =
"http://static.gaoshouyou.com/d/3a/93/573ae1db9493a801c24bf66128b11e39.apk";
+ //private static final String DOWNLOAD_URL =
+ // "http://img13.poco.cn/mypoco/myphoto/20120828/15/55689209201208281549023849547194135_001.jpg";
@Bind(R.id.progressBar) HorizontalProgressBarWithNumber mPb;
@Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop;
@@ -60,6 +65,7 @@ public class SingleTaskActivity extends BaseActivity {
@Bind(R.id.size) TextView mSize;
@Bind(R.id.toolbar) Toolbar toolbar;
@Bind(R.id.speed) TextView mSpeed;
+ @Bind(R.id.img) ImageView mImg;
private DownloadEntity mEntity;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
@@ -76,14 +82,14 @@ public class SingleTaskActivity extends BaseActivity {
switch (msg.what) {
case DOWNLOAD_RUNNING:
Task task = (Task) msg.obj;
- long current = task.getDownloadEntity().getCurrentProgress();
- long len = task.getDownloadEntity().getFileSize();
+ long current = task.getCurrentProgress();
+ long len = task.getFileSize();
if (len == 0) {
mPb.setProgress(0);
} else {
mPb.setProgress((int) ((current * 100) / len));
}
- mSpeed.setText(CommonUtil.formatFileSize(task.getDownloadEntity().getSpeed()) + "/s");
+ mSpeed.setText(CommonUtil.formatFileSize(task.getSpeed()) + "/s");
break;
case DOWNLOAD_PRE:
mSize.setText(CommonUtil.formatFileSize((Long) msg.obj));
@@ -117,6 +123,11 @@ public class SingleTaskActivity extends BaseActivity {
mStart.setText("重新开始?");
mCancel.setEnabled(false);
setBtState(true);
+
+ //String path = Environment.getExternalStorageDirectory().getPath() + "/test.jpg";
+ //Bitmap bm = BitmapFactory.decodeFile(path);
+ //mImg.setImageBitmap(bm);
+
break;
}
}
@@ -159,21 +170,10 @@ public class SingleTaskActivity extends BaseActivity {
}
private void init() {
- mEntity = Aria.get(this).getDownloadEntity(DOWNLOAD_URL);
- if (mEntity != null) {
- mPb.setProgress((int) ((mEntity.getCurrentProgress() * 100) / mEntity.getFileSize()));
- mSize.setText(CommonUtil.formatFileSize(mEntity.getFileSize()));
- if (mEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) {
- setBtState(false);
- } else if (mEntity.isDownloadComplete()) {
- mStart.setText("重新开始?");
- setBtState(true);
- }
- } else {
- mEntity = new DownloadEntity();
- mEntity.setFileName("test.apk");
- mEntity.setDownloadUrl(DOWNLOAD_URL);
- mEntity.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk");
+ if (Aria.get(this).taskExists(DOWNLOAD_URL)) {
+ AMTarget target = Aria.whit(this).load(DOWNLOAD_URL);
+ int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
+ mPb.setProgress(p);
}
}
@@ -197,22 +197,28 @@ public class SingleTaskActivity extends BaseActivity {
}
private void resume() {
- Aria.whit(this).load(mEntity).resume();
+ Aria.whit(this).load(DOWNLOAD_URL).resume();
}
private void start() {
- Aria.whit(this).load(mEntity).start();
+ Aria.whit(this)
+ .load(DOWNLOAD_URL)
+ .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk")
+ .setDownloadName("test.apk")
+ //.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.jpg")
+ //.setDownloadName("test.jpg")
+ .start();
}
private void stop() {
- Aria.whit(this).load(mEntity).stop();
+ Aria.whit(this).load(DOWNLOAD_URL).stop();
}
private void cancel() {
- Aria.whit(this).load(mEntity).cancel();
+ Aria.whit(this).load(DOWNLOAD_URL).cancel();
}
- private class MySchedulerListener extends AMTarget.SimpleSchedulerListener {
+ private class MySchedulerListener extends Aria.SimpleSchedulerListener {
@Override public void onTaskStart(Task task) {
mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize())
.sendToTarget();
@@ -220,8 +226,7 @@ public class SingleTaskActivity extends BaseActivity {
@Override public void onTaskResume(Task task) {
super.onTaskResume(task);
- mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize())
- .sendToTarget();
+ mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getFileSize()).sendToTarget();
}
@Override public void onTaskStop(Task task) {
diff --git a/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java b/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java
index f1138402..02b26c9a 100644
--- a/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java
+++ b/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java
@@ -19,6 +19,7 @@ package com.arialyy.simple.adapter;
import android.content.Context;
import android.content.res.Resources;
+import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
diff --git a/app/src/main/res/layout/content_single.xml b/app/src/main/res/layout/content_single.xml
index 8a620180..65d19cfb 100644
--- a/app/src/main/res/layout/content_single.xml
+++ b/app/src/main/res/layout/content_single.xml
@@ -35,6 +35,7 @@
+
+