pull/330/head
AriaLyy 8 years ago
parent ad6ea4fac9
commit bae48a4126
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
  2. 15
      Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java

@ -85,7 +85,7 @@ public class DownloadTaskQueue
}
startTask(task);
for (DownloadTask temp : tempTasks){
for (DownloadTask temp : tempTasks) {
mExecutePool.putTask(temp);
}
}

@ -38,20 +38,19 @@ public abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY ex
protected QUEUE mQueue;
private Map<String, IDownloadSchedulerListener<TASK>> mSchedulerListeners =
new ConcurrentHashMap<>();
private Map<String, ISchedulerListener<TASK>> mSchedulerListeners = new ConcurrentHashMap<>();
@Override
public void addSchedulerListener(String targetName, ISchedulerListener<TASK> schedulerListener) {
mSchedulerListeners.put(targetName, (IDownloadSchedulerListener<TASK>) schedulerListener);
mSchedulerListeners.put(targetName, schedulerListener);
}
@Override public void removeSchedulerListener(String targetName,
ISchedulerListener<TASK> schedulerListener) {
//该内存泄露解决方案:http://stackoverflow.com/questions/14585829/how-safe-is-to-delete-already-removed-concurrenthashmap-element
for (Iterator<Map.Entry<String, IDownloadSchedulerListener<TASK>>> iter =
for (Iterator<Map.Entry<String, ISchedulerListener<TASK>>> iter =
mSchedulerListeners.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<String, IDownloadSchedulerListener<TASK>> entry = iter.next();
Map.Entry<String, ISchedulerListener<TASK>> entry = iter.next();
if (entry.getKey().equals(targetName)) iter.remove();
}
}
@ -99,7 +98,7 @@ public abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY ex
}
}
private void callback(int state, TASK task, IDownloadSchedulerListener<TASK> listener) {
private void callback(int state, TASK task, ISchedulerListener<TASK> listener) {
if (listener != null) {
if (task == null) {
Log.e(TAG, "TASK 为null,回调失败");
@ -134,7 +133,9 @@ public abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY ex
listener.onTaskFail(task);
break;
case SUPPORT_BREAK_POINT:
listener.onNoSupportBreakPoint(task);
if (listener instanceof IDownloadSchedulerListener) {
((IDownloadSchedulerListener<TASK>) listener).onNoSupportBreakPoint(task);
}
break;
}
}

@ -497,7 +497,7 @@ final class SqlHelper extends SQLiteOpenHelper {
}
private static void close(SQLiteDatabase db) {
if (db != null && db.isOpen()) db.close();
//if (db != null && db.isOpen()) db.close();
}
private static SQLiteDatabase checkDb(SQLiteDatabase db) {

Loading…
Cancel
Save