Local manga in zip/cbz/folder format (#648)
* add local source * small fixes * change Chapter to SChapter and and Manga to SManga in ChapterRecognition. Use ChapterRecognition.parseChapterNumber() to recognize chapter numbers. * use thread poll * update isImage() * add isImage() function to DiskUtil * improve cover handling * Support external SD cards * use R.string.app_name as root folder name
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package eu.kanade.tachiyomi.data.glide
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.LruCache
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.load.data.DataFetcher
|
||||
import com.bumptech.glide.load.model.*
|
||||
import com.bumptech.glide.load.model.stream.StreamModelLoader
|
||||
@@ -43,6 +45,12 @@ class MangaModelLoader(context: Context) : StreamModelLoader<Manga> {
|
||||
private val baseLoader = Glide.buildModelLoader(GlideUrl::class.java,
|
||||
InputStream::class.java, context)
|
||||
|
||||
/**
|
||||
* Base file loader.
|
||||
*/
|
||||
private val baseFileLoader = Glide.buildModelLoader(Uri::class.java,
|
||||
InputStream::class.java, context)
|
||||
|
||||
/**
|
||||
* LRU cache whose key is the thumbnail url of the manga, and the value contains the request url
|
||||
* and the file where it should be stored in case the manga is a favorite.
|
||||
@@ -82,6 +90,18 @@ class MangaModelLoader(context: Context) : StreamModelLoader<Manga> {
|
||||
return null
|
||||
}
|
||||
|
||||
if (url!!.startsWith("file://")) {
|
||||
val cover = File(url.substring(7))
|
||||
val id = url + File.separator + cover.lastModified()
|
||||
val rf = baseFileLoader.getResourceFetcher(Uri.fromFile(cover), width, height)
|
||||
return object : DataFetcher<InputStream> {
|
||||
override fun cleanup() = rf.cleanup()
|
||||
override fun loadData(priority: Priority?): InputStream = rf.loadData(priority)
|
||||
override fun cancel() = rf.cancel()
|
||||
override fun getId() = id
|
||||
}
|
||||
}
|
||||
|
||||
// Obtain the request url and the file for this url from the LRU cache, or calculate it
|
||||
// and add them to the cache.
|
||||
val (glideUrl, file) = lruCache.get(url) ?:
|
||||
|
||||
Reference in New Issue
Block a user