Performance improvements for library filters

This commit is contained in:
len
2016-03-06 15:31:21 +01:00
committed by NoodleMage
parent 8fbef4b4bb
commit b89d6644d8
3 changed files with 35 additions and 37 deletions

View File

@@ -378,17 +378,21 @@ public class DownloadManager {
savePageList(download.source, download.manga, download.chapter, download.pages);
}
// Get the absolute path to the chapter directory
public File getAbsoluteChapterDirectory(Source source, Manga manga, Chapter chapter) {
public File getAbsoluteMangaDirectory(Source source, Manga manga) {
String chapterRelativePath = source.getName() +
File.separator +
manga.title.replaceAll("[^\\sa-zA-Z0-9.-]", "_") +
File.separator +
chapter.name.replaceAll("[^\\sa-zA-Z0-9.-]", "_");
manga.title.replaceAll("[^\\sa-zA-Z0-9.-]", "_");
return new File(preferences.getDownloadsDirectory(), chapterRelativePath);
}
// Get the absolute path to the chapter directory
public File getAbsoluteChapterDirectory(Source source, Manga manga, Chapter chapter) {
String chapterRelativePath = chapter.name.replaceAll("[^\\sa-zA-Z0-9.-]", "_");
return new File(getAbsoluteMangaDirectory(source, manga), chapterRelativePath);
}
// Shortcut for the method above
private File getAbsoluteChapterDirectory(Download download) {
return getAbsoluteChapterDirectory(download.source, download.manga, download.chapter);

View File

@@ -11,6 +11,10 @@ import eu.kanade.tachiyomi.data.source.base.Source
import java.io.File
import java.io.IOException
fun <T> Preference<T>.getOrDefault(): T {
return get() ?: defaultValue()!!
}
class PreferencesHelper(private val context: Context) {
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)