forked from mihonapp/mihon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor archive support with libarchive
- Loading branch information
Showing
67 changed files
with
265 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ArchivePageLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 tachiyomi.core.archive.ArchiveReader | ||
import tachiyomi.core.util.system.ImageUtil | ||
|
||
/** | ||
* Loader used to load a chapter from an archive file. | ||
*/ | ||
internal class ArchivePageLoader(private val reader: ArchiveReader) : PageLoader() { | ||
override var isLocal: Boolean = true | ||
|
||
override suspend fun getPages(): List<ReaderPage> = | ||
reader.useEntries { entries -> | ||
entries | ||
.filter { it.isFile && ImageUtil.isImage(it.name) { reader.getInputStream(it.name)!! } } | ||
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) } | ||
.mapIndexed { i, entry -> | ||
ReaderPage(i).apply { | ||
stream = { reader.getInputStream(entry.name)!! } | ||
status = Page.State.READY | ||
} | ||
}.toList() | ||
} | ||
|
||
override suspend fun loadPage(page: ReaderPage) { | ||
check(!isRecycled) | ||
} | ||
|
||
override fun recycle() { | ||
super.recycle() | ||
reader.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.