From 560f0bba5c8b6d3ba232b9cffaaa15557e0cdff5 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 7 Dec 2020 22:13:53 -0500 Subject: [PATCH] Use more up-to-date fork of junrar --- app/build.gradle | 2 +- .../java/eu/kanade/tachiyomi/source/LocalSource.kt | 12 +++++------- .../tachiyomi/ui/reader/loader/RarPageLoader.kt | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 19475531c0..e60d74bdd2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -195,7 +195,7 @@ dependencies { // Disk implementation 'com.jakewharton:disklrucache:2.0.2' implementation 'com.github.inorichi:unifile:e9ee588' - implementation 'com.github.inorichi:junrar-android:634c1f5' + implementation 'com.github.junrar:junrar:7.4.0' // HTML parser implementation 'org.jsoup:jsoup:1.13.1' diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 9ab3c2ae18..2c8815270e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.source import android.content.Context +import com.github.junrar.Archive import com.google.gson.JsonParser import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.model.Filter @@ -14,8 +15,6 @@ import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.EpubFile import eu.kanade.tachiyomi.util.system.ImageUtil -import junrar.Archive -import junrar.rarfile.FileHeader import rx.Observable import timber.log.Timber import java.io.File @@ -23,7 +22,6 @@ import java.io.FileInputStream import java.io.InputStream import java.util.Locale import java.util.concurrent.TimeUnit -import java.util.zip.ZipEntry import java.util.zip.ZipFile class LocalSource(private val context: Context) : CatalogueSource { @@ -278,7 +276,7 @@ class LocalSource(private val context: Context) : CatalogueSource { return when (val format = getFormat(chapter)) { is Format.Directory -> { val entry = format.file.listFiles() - ?.sortedWith(Comparator { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }) + ?.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) } ?.find { !it.isDirectory && ImageUtil.isImage(it.name) { FileInputStream(it) } } entry?.let { updateCover(context, manga, it.inputStream()) } @@ -286,7 +284,7 @@ class LocalSource(private val context: Context) : CatalogueSource { is Format.Zip -> { ZipFile(format.file).use { zip -> val entry = zip.entries().toList() - .sortedWith(Comparator { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }) + .sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) } .find { !it.isDirectory && ImageUtil.isImage(it.name) { zip.getInputStream(it) } } entry?.let { updateCover(context, manga, zip.getInputStream(it)) } @@ -295,8 +293,8 @@ class LocalSource(private val context: Context) : CatalogueSource { is Format.Rar -> { Archive(format.file).use { archive -> val entry = archive.fileHeaders - .sortedWith(Comparator { f1, f2 -> f1.fileNameString.compareToCaseInsensitiveNaturalOrder(f2.fileNameString) }) - .find { !it.isDirectory && ImageUtil.isImage(it.fileNameString) { archive.getInputStream(it) } } + .sortedWith { f1, f2 -> f1.fileName.compareToCaseInsensitiveNaturalOrder(f2.fileName) } + .find { !it.isDirectory && ImageUtil.isImage(it.fileName) { archive.getInputStream(it) } } entry?.let { updateCover(context, manga, archive.getInputStream(it)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt index 9a6a6b88c6..01c7a632e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt @@ -1,11 +1,11 @@ package eu.kanade.tachiyomi.ui.reader.loader +import com.github.junrar.Archive +import com.github.junrar.rarfile.FileHeader import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.system.ImageUtil -import junrar.Archive -import junrar.rarfile.FileHeader import rx.Observable import java.io.File import java.io.InputStream @@ -43,8 +43,8 @@ class RarPageLoader(file: File) : PageLoader() { */ override fun getPages(): Observable> { return archive.fileHeaders - .filter { !it.isDirectory && ImageUtil.isImage(it.fileNameString) { archive.getInputStream(it) } } - .sortedWith(Comparator { f1, f2 -> f1.fileNameString.compareToCaseInsensitiveNaturalOrder(f2.fileNameString) }) + .filter { !it.isDirectory && ImageUtil.isImage(it.fileName) { archive.getInputStream(it) } } + .sortedWith { f1, f2 -> f1.fileName.compareToCaseInsensitiveNaturalOrder(f2.fileName) } .mapIndexed { i, header -> val streamFn = { getStream(header) }