mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-21 12:45:44 +03:00
Address ZipFile
deprecation warning
This commit is contained in:
parent
4bfc5e7b51
commit
9d5978aca0
4 changed files with 15 additions and 7 deletions
|
@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.loader
|
|||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile
|
||||
import mihon.core.common.extensions.toZipFile
|
||||
import tachiyomi.core.common.util.system.ImageUtil
|
||||
import java.nio.channels.SeekableByteChannel
|
||||
|
||||
|
@ -12,7 +12,7 @@ import java.nio.channels.SeekableByteChannel
|
|||
*/
|
||||
internal class ZipPageLoader(channel: SeekableByteChannel) : PageLoader() {
|
||||
|
||||
private val zip = ZipFile(channel)
|
||||
private val zip = channel.toZipFile()
|
||||
|
||||
override var isLocal: Boolean = true
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.kanade.tachiyomi.util.storage
|
||||
|
||||
import mihon.core.common.extensions.toZipFile
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import java.io.Closeable
|
||||
|
@ -17,7 +17,7 @@ class EpubFile(channel: SeekableByteChannel) : Closeable {
|
|||
/**
|
||||
* Zip file of this epub.
|
||||
*/
|
||||
private val zip = ZipFile(channel)
|
||||
private val zip = channel.toZipFile()
|
||||
|
||||
/**
|
||||
* Path separator used by this epub.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package mihon.core.common.extensions
|
||||
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile
|
||||
import java.nio.channels.SeekableByteChannel
|
||||
|
||||
fun SeekableByteChannel.toZipFile(): ZipFile {
|
||||
return ZipFile.Builder().setSeekableByteChannel(this).get()
|
||||
}
|
|
@ -16,9 +16,9 @@ import kotlinx.coroutines.awaitAll
|
|||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.decodeFromStream
|
||||
import logcat.LogPriority
|
||||
import mihon.core.common.extensions.toZipFile
|
||||
import nl.adaptivity.xmlutil.AndroidXmlReader
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE
|
||||
import tachiyomi.core.metadata.comicinfo.ComicInfo
|
||||
|
@ -210,7 +210,7 @@ actual class LocalSource(
|
|||
for (chapter in chapterArchives) {
|
||||
when (Format.valueOf(chapter)) {
|
||||
is Format.Zip -> {
|
||||
ZipFile(chapter.openReadOnlyChannel(context)).use { zip: ZipFile ->
|
||||
chapter.openReadOnlyChannel(context).toZipFile().use { zip ->
|
||||
zip.getEntry(COMIC_INFO_FILE)?.let { comicInfoFile ->
|
||||
zip.getInputStream(comicInfoFile).buffered().use { stream ->
|
||||
return copyComicInfoFile(stream, folder)
|
||||
|
@ -328,7 +328,7 @@ actual class LocalSource(
|
|||
entry?.let { coverManager.update(manga, it.openInputStream()) }
|
||||
}
|
||||
is Format.Zip -> {
|
||||
ZipFile(format.file.openReadOnlyChannel(context)).use { zip ->
|
||||
format.file.openReadOnlyChannel(context).toZipFile().use { zip ->
|
||||
val entry = zip.entries.toList()
|
||||
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
||||
.find { !it.isDirectory && ImageUtil.isImage(it.name) { zip.getInputStream(it) } }
|
||||
|
|
Loading…
Reference in a new issue