Improve download discovery performance in library updates view

This commit is contained in:
len
2016-12-09 20:23:48 +01:00
parent 8b60d5bfcb
commit f98e0858a7
4 changed files with 49 additions and 7 deletions

View File

@@ -110,6 +110,15 @@ class DownloadManager(context: Context) {
}
}
/**
* Returns the directory name for a manga.
*
* @param manga the manga to query.
*/
fun getMangaDirName(manga: Manga): String {
return provider.getMangaDirName(manga)
}
/**
* Returns the directory name for the given chapter.
*
@@ -119,6 +128,15 @@ class DownloadManager(context: Context) {
return provider.getChapterDirName(chapter)
}
/**
* Returns the download directory for a source if it exists.
*
* @param source the source to query.
*/
fun findSourceDir(source: Source): UniFile? {
return provider.findSourceDir(source)
}
/**
* Returns the directory for the given manga, if it exists.
*

View File

@@ -45,6 +45,15 @@ class DownloadProvider(private val context: Context) {
.createDirectory(getMangaDirName(manga))
}
/**
* Returns the download directory for a source if it exists.
*
* @param source the source to query.
*/
fun findSourceDir(source: Source): UniFile? {
return downloadsDir.findFile(getSourceDirName(source))
}
/**
* Returns the download directory for a manga if it exists.
*
@@ -52,7 +61,7 @@ class DownloadProvider(private val context: Context) {
* @param manga the manga to query.
*/
fun findMangaDir(source: Source, manga: Manga): UniFile? {
val sourceDir = downloadsDir.findFile(getSourceDirName(source))
val sourceDir = findSourceDir(source)
return sourceDir?.findFile(getMangaDirName(manga))
}