Fixed image loading error
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":42,"versionName":"4.6-alpha6","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":42,"versionName":"4.6-alpha7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -58,7 +58,7 @@ class ReaderAdapter(private val context: Context,
|
|||||||
}
|
}
|
||||||
val modelProvider = object: ListPreloader.PreloadModelProvider<File> {
|
val modelProvider = object: ListPreloader.PreloadModelProvider<File> {
|
||||||
override fun getPreloadItems(position: Int): MutableList<File> {
|
override fun getPreloadItems(position: Int): MutableList<File> {
|
||||||
return listOf(Cache(context).getImages(galleryID)?.get(position)).filterNotNullTo(mutableListOf())
|
return listOf(Cache(context).getImages(galleryID)?.getOrNull(position)).filterNotNullTo(mutableListOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPreloadRequestBuilder(item: File): RequestBuilder<*>? {
|
override fun getPreloadRequestBuilder(item: File): RequestBuilder<*>? {
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//addOnScrollListener((adapter as ReaderAdapter).preloader)
|
addOnScrollListener((adapter as ReaderAdapter).preloader)
|
||||||
addOnScrollListener(object: RecyclerView.OnScrollListener() {
|
addOnScrollListener(object: RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
|
|||||||
@@ -178,24 +178,27 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
return reader
|
return reader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val imageNameRegex = Regex("""^\d+\..+$""")
|
||||||
fun getImages(galleryID: Int): List<File?>? {
|
fun getImages(galleryID: Int): List<File?>? {
|
||||||
val gallery = getCachedGallery(galleryID)
|
val gallery = getCachedGallery(galleryID)
|
||||||
val reader = getReaderOrNull(galleryID) ?: return null
|
|
||||||
val images = gallery.listFiles() ?: return null
|
|
||||||
|
|
||||||
return reader.galleryInfo.indices.map { index ->
|
return gallery.list { _, name ->
|
||||||
images.firstOrNull { file -> file.name.startsWith("%05d".format(index)) }
|
imageNameRegex.matches(name)
|
||||||
|
}?.map {
|
||||||
|
File(gallery, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageExts = listOf(
|
val imageExtensions = listOf(
|
||||||
|
"png",
|
||||||
"jpg",
|
"jpg",
|
||||||
"webp"
|
"webp",
|
||||||
|
"gif"
|
||||||
)
|
)
|
||||||
fun getImage(galleryID: Int, index: Int): File? {
|
fun getImage(galleryID: Int, index: Int): File? {
|
||||||
val gallery = getCachedGallery(galleryID)
|
val gallery = getCachedGallery(galleryID)
|
||||||
|
|
||||||
for (ext in imageExts) {
|
for (ext in imageExtensions) {
|
||||||
File(gallery, "%05d.$ext".format(index)).let {
|
File(gallery, "%05d.$ext".format(index)).let {
|
||||||
if (it.exists())
|
if (it.exists())
|
||||||
return it
|
return it
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.content.Context
|
|||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Log
|
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
@@ -253,15 +252,13 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
|||||||
val cache = Cache(this@DownloadWorker).getImages(galleryID)
|
val cache = Cache(this@DownloadWorker).getImages(galleryID)
|
||||||
|
|
||||||
progress.put(galleryID, reader.galleryInfo.indices.map { index ->
|
progress.put(galleryID, reader.galleryInfo.indices.map { index ->
|
||||||
if (cache?.get(index) != null)
|
if (cache?.getOrNull(index) != null)
|
||||||
Float.POSITIVE_INFINITY
|
Float.POSITIVE_INFINITY
|
||||||
else
|
else
|
||||||
0F
|
0F
|
||||||
}.toMutableList())
|
}.toMutableList())
|
||||||
exception.put(galleryID, reader.galleryInfo.map { null }.toMutableList())
|
exception.put(galleryID, reader.galleryInfo.map { null }.toMutableList())
|
||||||
|
|
||||||
Log.i("PUPILD", "READER HERE!")
|
|
||||||
|
|
||||||
if (notification[galleryID] == null)
|
if (notification[galleryID] == null)
|
||||||
initNotification(galleryID)
|
initNotification(galleryID)
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,6 @@ fun getSuggestionsFromData(field: String, data: Pair<Long, Int>) : List<Suggesti
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getGalleryIDsFromNozomi(area: String?, tag: String, language: String) : List<Int> {
|
fun getGalleryIDsFromNozomi(area: String?, tag: String, language: String) : List<Int> {
|
||||||
print("PUPILD: NOZOMI REQUEST: $area:$tag ($language)")
|
|
||||||
val nozomiAddress =
|
val nozomiAddress =
|
||||||
when(area) {
|
when(area) {
|
||||||
null -> "$protocol//$domain/$compressed_nozomi_prefix/$tag-$language$nozomiextension"
|
null -> "$protocol//$domain/$compressed_nozomi_prefix/$tag-$language$nozomiextension"
|
||||||
@@ -189,7 +188,6 @@ fun getGalleryIDsFromNozomi(area: String?, tag: String, language: String) : List
|
|||||||
while (arrayBuffer.hasRemaining())
|
while (arrayBuffer.hasRemaining())
|
||||||
nozomi.add(arrayBuffer.int)
|
nozomi.add(arrayBuffer.int)
|
||||||
|
|
||||||
print("PUPILD: NOZOMI REQUEST END: $area:$tag ($language)")
|
|
||||||
return nozomi
|
return nozomi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user