Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class BitmapFileWatcher {
mFileWatcherExecutor = new ThreadPoolExecutor(0, 1,
100L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(1), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
mFileWatcherExecutor.execute(BitmapFileWatcher::loadAllFileToMemory);
}

/**
Expand All @@ -64,6 +63,7 @@ public static void unregisterFileListener(BitmapFileListener fileListener) {

/**
* 根据配置,决定是每次重启就删除之前的文件,还是在运行时超出后就删除
*
* @param bmpRootPath
* @param clearAllFileWhenRestartApp
* @param clearFileWhenOutOfThreshold
Expand All @@ -83,6 +83,7 @@ public static void init(String bmpRootPath, boolean clearAllFileWhenRestartApp,
deleteDir(file);
}
}
mFileWatcherExecutor.execute(BitmapFileWatcher::loadAllFileToMemory);
}

public static void startWatch(String path) {
Expand All @@ -107,8 +108,10 @@ private static void loadAllFileToMemory() {
File[] files = rootPath.listFiles();
if (files == null) return;

// collects total file size to determine whether to delete files
mAllFiles.clear();
mUsedTotalSize = 0;

// collects total file size to determine whether to delete files
for (File file : files) mUsedTotalSize += file.length();

mAllFiles.addAll(Arrays.asList(files));
Expand Down