From bae48a4126266810e405374ef265b023721e4328 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 5 Jun 2017 10:25:18 +0800 Subject: [PATCH] bug fix --- .../aria/core/queue/DownloadTaskQueue.java | 2 +- .../aria/core/scheduler/AbsSchedulers.java | 15 ++++++++------- .../main/java/com/arialyy/aria/orm/SqlHelper.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java index e51daeb5..0a8aa594 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java @@ -85,7 +85,7 @@ public class DownloadTaskQueue } startTask(task); - for (DownloadTask temp : tempTasks){ + for (DownloadTask temp : tempTasks) { mExecutePool.putTask(temp); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java index 3942ca61..f8f26021 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java @@ -38,20 +38,19 @@ public abstract class AbsSchedulers> mSchedulerListeners = - new ConcurrentHashMap<>(); + private Map> mSchedulerListeners = new ConcurrentHashMap<>(); @Override public void addSchedulerListener(String targetName, ISchedulerListener schedulerListener) { - mSchedulerListeners.put(targetName, (IDownloadSchedulerListener) schedulerListener); + mSchedulerListeners.put(targetName, schedulerListener); } @Override public void removeSchedulerListener(String targetName, ISchedulerListener schedulerListener) { //该内存泄露解决方案:http://stackoverflow.com/questions/14585829/how-safe-is-to-delete-already-removed-concurrenthashmap-element - for (Iterator>> iter = + for (Iterator>> iter = mSchedulerListeners.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry> entry = iter.next(); + Map.Entry> entry = iter.next(); if (entry.getKey().equals(targetName)) iter.remove(); } } @@ -99,7 +98,7 @@ public abstract class AbsSchedulers listener) { + private void callback(int state, TASK task, ISchedulerListener listener) { if (listener != null) { if (task == null) { Log.e(TAG, "TASK 为null,回调失败"); @@ -134,7 +133,9 @@ public abstract class AbsSchedulers) listener).onNoSupportBreakPoint(task); + } break; } } 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 e13f5492..f3f82bde 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -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) {