Compare commits
8 Commits
5.1.9-hotf
...
5.1.11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44aea606b7 | ||
|
|
a05dc8c661 | ||
|
|
1f80e36017 | ||
|
|
1efca40744 | ||
|
|
9c7320c0a0 | ||
|
|
02c17c3b75 | ||
|
|
49a47f4b4f | ||
|
|
4c9aa29d46 |
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="1.8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
10
.idea/jarRepositories.xml
generated
10
.idea/jarRepositories.xml
generated
@@ -71,5 +71,15 @@
|
|||||||
<option name="name" value="maven3" />
|
<option name="name" value="maven3" />
|
||||||
<option name="url" value="http://dl.bintray.com/piasy/maven" />
|
<option name="url" value="http://dl.bintray.com/piasy/maven" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven2" />
|
||||||
|
<option name="name" value="maven2" />
|
||||||
|
<option name="url" value="https://guardian.github.io/maven/repo-releases/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenLocal" />
|
||||||
|
<option name="name" value="MavenLocal" />
|
||||||
|
<option name="url" value="file:$USER_HOME$/.m2/repository/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
1
.idea/runConfigurations.xml
generated
1
.idea/runConfigurations.xml
generated
@@ -3,6 +3,7 @@
|
|||||||
<component name="RunConfigurationProducerService">
|
<component name="RunConfigurationProducerService">
|
||||||
<option name="ignoredProducers">
|
<option name="ignoredProducers">
|
||||||
<set>
|
<set>
|
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
|||||||
@@ -37,22 +37,22 @@ android {
|
|||||||
applicationId "xyz.quaver.pupil"
|
applicationId "xyz.quaver.pupil"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 64
|
versionCode 66
|
||||||
versionName "5.1.9"
|
versionName "5.1.10"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled true
|
defaultConfig.minSdkVersion 21
|
||||||
shrinkResources true
|
|
||||||
|
minifyEnabled false
|
||||||
|
shrinkResources false
|
||||||
|
|
||||||
debuggable true
|
debuggable true
|
||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
versionNameSuffix "-DEBUG"
|
versionNameSuffix "-DEBUG"
|
||||||
|
|
||||||
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
|
||||||
|
|
||||||
ext.enableCrashlytics = false
|
ext.enableCrashlytics = false
|
||||||
ext.alwaysUpdateBuildId = false
|
ext.alwaysUpdateBuildId = false
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation "ru.noties.markwon:core:3.1.0"
|
implementation "ru.noties.markwon:core:3.1.0"
|
||||||
|
|
||||||
implementation "xyz.quaver:libpupil:2.1.0"
|
implementation "xyz.quaver:libpupil:2.1.3"
|
||||||
implementation "xyz.quaver:documentfilex:0.6.1"
|
implementation "xyz.quaver:documentfilex:0.6.1"
|
||||||
implementation "xyz.quaver:floatingsearchview:1.1.7"
|
implementation "xyz.quaver:floatingsearchview:1.1.7"
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
{
|
{
|
||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"versionCode": 64,
|
"versionCode": 66,
|
||||||
"versionName": "5.1.9",
|
"versionName": "5.1.10",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ReaderAdapter(
|
|||||||
private val activity: ReaderActivity,
|
private val activity: ReaderActivity,
|
||||||
private val galleryID: Int
|
private val galleryID: Int
|
||||||
) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
||||||
var reader: GalleryInfo? = null
|
var galleryInfo: GalleryInfo? = null
|
||||||
|
|
||||||
var isFullScreen = false
|
var isFullScreen = false
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ class ReaderAdapter(
|
|||||||
binding.image.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
binding.image.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
height = 0
|
height = 0
|
||||||
dimensionRatio =
|
dimensionRatio =
|
||||||
"${reader!!.files[position].width}:${reader!!.files[position].height}"
|
"${galleryInfo!!.files[position].width}:${galleryInfo!!.files[position].height}"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.root.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
|
binding.root.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
@@ -158,7 +158,7 @@ class ReaderAdapter(
|
|||||||
holder.bind(position)
|
holder.bind(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = reader?.files?.size ?: 0
|
override fun getItemCount() = galleryInfo?.files?.size ?: 0
|
||||||
|
|
||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
holder.clear()
|
holder.clear()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class UpdateBroadcastReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
val uri = downloadManager.query(query).use { cursor ->
|
val uri = downloadManager.query(query).use { cursor ->
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)).let {
|
cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))?.let {
|
||||||
val uri = Uri.parse(it)
|
val uri = Uri.parse(it)
|
||||||
|
|
||||||
when (uri.scheme) {
|
when (uri.scheme) {
|
||||||
|
|||||||
@@ -305,10 +305,10 @@ class DownloadService : Service() {
|
|||||||
|
|
||||||
initNotification(galleryID)
|
initNotification(galleryID)
|
||||||
|
|
||||||
val reader = cache.getReader()
|
val galleryInfo = cache.getGalleryInfo()
|
||||||
|
|
||||||
// Gallery doesn't exist
|
// Gallery doesn't exist
|
||||||
if (reader == null) {
|
if (galleryInfo == null) {
|
||||||
delete(galleryID)
|
delete(galleryID)
|
||||||
progress[galleryID] = mutableListOf()
|
progress[galleryID] = mutableListOf()
|
||||||
return@launch
|
return@launch
|
||||||
@@ -316,7 +316,7 @@ class DownloadService : Service() {
|
|||||||
|
|
||||||
histories.add(galleryID)
|
histories.add(galleryID)
|
||||||
|
|
||||||
progress[galleryID] = MutableList(reader.files.size) { 0F }
|
progress[galleryID] = MutableList(galleryInfo.files.size) { 0F }
|
||||||
|
|
||||||
cache.metadata.imageList?.let {
|
cache.metadata.imageList?.let {
|
||||||
it.forEachIndexed { index, image ->
|
it.forEachIndexed { index, image ->
|
||||||
@@ -334,7 +334,7 @@ class DownloadService : Service() {
|
|||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
notification[galleryID]?.setContentTitle(reader.title?.ellipsize(30))
|
notification[galleryID]?.setContentTitle(galleryInfo.title?.ellipsize(30))
|
||||||
notify(galleryID)
|
notify(galleryID)
|
||||||
|
|
||||||
val queued = mutableSetOf<Int>()
|
val queued = mutableSetOf<Int>()
|
||||||
@@ -348,7 +348,7 @@ class DownloadService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.requestBuilders.forEachIndexed { index, it ->
|
galleryInfo.requestBuilders.forEachIndexed { index, it ->
|
||||||
if (progress[galleryID]?.get(index)?.isInfinite() == false) {
|
if (progress[galleryID]?.get(index)?.isInfinite() == false) {
|
||||||
val request = it.tag(Tag(galleryID, index, startId)).build()
|
val request = it.tag(Tag(galleryID, index, startId)).build()
|
||||||
client.newCall(request).enqueue(callback)
|
client.newCall(request).enqueue(callback)
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import android.view.animation.DecelerateInterpolator
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.cardview.widget.CardView
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
@@ -125,11 +124,10 @@ class MainActivity :
|
|||||||
if (Preferences["download_folder", ""].isEmpty())
|
if (Preferences["download_folder", ""].isEmpty())
|
||||||
DownloadLocationDialogFragment().show(supportFragmentManager, "Download Location Dialog")
|
DownloadLocationDialogFragment().show(supportFragmentManager, "Download Location Dialog")
|
||||||
|
|
||||||
checkUpdate(this)
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
|
||||||
!Preferences["download_folder_ignore_warning", false] &&
|
!Preferences["download_folder_ignore_warning", false] &&
|
||||||
ContextCompat.getExternalFilesDirs(this, null).map { Uri.fromFile(it).toString() }
|
ContextCompat.getExternalFilesDirs(this, null).filterNotNull().map { Uri.fromFile(it).toString() }
|
||||||
.contains(Preferences["download_folder", ""])
|
.contains(Preferences["download_folder", ""])
|
||||||
) {
|
) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
@@ -145,6 +143,12 @@ class MainActivity :
|
|||||||
initView()
|
initView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
|
checkUpdate(this)
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
when {
|
when {
|
||||||
@@ -797,7 +801,7 @@ class MainActivity :
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
||||||
if (e.message != "No result")
|
if (e !is CancellationException)
|
||||||
FirebaseCrashlytics.getInstance().recordException(e)
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class ReaderActivity : BaseActivity() {
|
|||||||
|
|
||||||
with(binding.numberPicker) {
|
with(binding.numberPicker) {
|
||||||
minValue = 1
|
minValue = 1
|
||||||
maxValue = cache.metadata.reader?.files?.size ?: 0
|
maxValue = cache.metadata.galleryInfo?.files?.size ?: 0
|
||||||
value = currentPage
|
value = currentPage
|
||||||
}
|
}
|
||||||
val dialog = AlertDialog.Builder(this).apply {
|
val dialog = AlertDialog.Builder(this).apply {
|
||||||
@@ -298,17 +298,17 @@ class ReaderActivity : BaseActivity() {
|
|||||||
downloader.progress[galleryID]?.count { it.isInfinite() } ?: 0
|
downloader.progress[galleryID]?.count { it.isInfinite() } ?: 0
|
||||||
|
|
||||||
if (title == getString(R.string.reader_loading)) {
|
if (title == getString(R.string.reader_loading)) {
|
||||||
val reader = cache.metadata.reader
|
val galleryInfo = cache.metadata.galleryInfo
|
||||||
|
|
||||||
if (reader != null) {
|
if (galleryInfo != null) {
|
||||||
with(binding.recyclerview.adapter as ReaderAdapter) {
|
with(binding.recyclerview.adapter as ReaderAdapter) {
|
||||||
this.reader = reader
|
this.galleryInfo = galleryInfo
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
title = reader.title
|
title = galleryInfo.title
|
||||||
menu?.findItem(R.id.reader_menu_page_indicator)?.title =
|
menu?.findItem(R.id.reader_menu_page_indicator)?.title =
|
||||||
"$currentPage/${reader.files.size}"
|
"$currentPage/${galleryInfo.files.size}"
|
||||||
|
|
||||||
menu?.findItem(R.id.reader_type)?.icon = ContextCompat.getDrawable(this@ReaderActivity, R.drawable.hitomi)
|
menu?.findItem(R.id.reader_type)?.icon = ContextCompat.getDrawable(this@ReaderActivity, R.drawable.hitomi)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
package xyz.quaver.pupil.util
|
package xyz.quaver.pupil.util
|
||||||
|
|
||||||
import kotlinx.serialization.*
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.serializer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class SavedSet <T: Any> (private val file: File, private val any: T, private val set: MutableSet<T> = mutableSetOf()) : MutableSet<T> by set {
|
class SavedSet <T: Any> (private val file: File, private val any: T, private val set: MutableSet<T> = mutableSetOf()) : MutableSet<T> by set {
|
||||||
|
|
||||||
@@ -46,6 +48,8 @@ class SavedSet <T: Any> (private val file: File, private val any: T, private val
|
|||||||
Json.decodeFromString(serializer, file.readText())
|
Json.decodeFromString(serializer, file.readText())
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
set.addAll(it)
|
set.addAll(it)
|
||||||
|
}.onFailure {
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +61,6 @@ class SavedSet <T: Any> (private val file: File, private val any: T, private val
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun add(element: T): Boolean {
|
override fun add(element: T): Boolean {
|
||||||
load()
|
|
||||||
|
|
||||||
set.remove(element)
|
set.remove(element)
|
||||||
|
|
||||||
return set.add(element).also {
|
return set.add(element).also {
|
||||||
@@ -68,8 +70,6 @@ class SavedSet <T: Any> (private val file: File, private val any: T, private val
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun addAll(elements: Collection<T>): Boolean {
|
override fun addAll(elements: Collection<T>): Boolean {
|
||||||
load()
|
|
||||||
|
|
||||||
set.removeAll(elements)
|
set.removeAll(elements)
|
||||||
|
|
||||||
return set.addAll(elements).also {
|
return set.addAll(elements).also {
|
||||||
@@ -79,8 +79,6 @@ class SavedSet <T: Any> (private val file: File, private val any: T, private val
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun remove(element: T): Boolean {
|
override fun remove(element: T): Boolean {
|
||||||
load()
|
|
||||||
|
|
||||||
return set.remove(element).also {
|
return set.remove(element).also {
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,18 +37,57 @@ import xyz.quaver.hitomi.GalleryInfo
|
|||||||
import xyz.quaver.io.FileX
|
import xyz.quaver.io.FileX
|
||||||
import xyz.quaver.io.util.*
|
import xyz.quaver.io.util.*
|
||||||
import xyz.quaver.pupil.client
|
import xyz.quaver.pupil.client
|
||||||
import xyz.quaver.pupil.util.Preferences
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Metadata(
|
data class OldGalleryBlock(
|
||||||
var galleryBlock: GalleryBlock? = null,
|
val code: String,
|
||||||
var reader: GalleryInfo? = null,
|
val id: Int,
|
||||||
|
val galleryUrl: String,
|
||||||
|
val thumbnails: List<String>,
|
||||||
|
val title: String,
|
||||||
|
val artists: List<String>,
|
||||||
|
val series: List<String>,
|
||||||
|
val type: String,
|
||||||
|
val language: String,
|
||||||
|
val relatedTags: List<String>
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OldReader(val code: String, val galleryInfo: GalleryInfo)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OldMetadata(
|
||||||
|
var galleryBlock: OldGalleryBlock? = null,
|
||||||
|
var reader: OldReader? = null,
|
||||||
var imageList: MutableList<String?>? = null
|
var imageList: MutableList<String?>? = null
|
||||||
) {
|
) {
|
||||||
fun copy(): Metadata = Metadata(galleryBlock, reader, imageList?.let { MutableList(it.size) { i -> it[i] } })
|
fun copy(): OldMetadata = OldMetadata(galleryBlock, reader, imageList?.let { MutableList(it.size) { i -> it[i] } })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Metadata(
|
||||||
|
var galleryBlock: GalleryBlock? = null,
|
||||||
|
var galleryInfo: GalleryInfo? = null,
|
||||||
|
var imageList: MutableList<String?>? = null
|
||||||
|
) {
|
||||||
|
constructor(old: OldMetadata) : this(old.galleryBlock?.let { galleryBlock -> GalleryBlock(
|
||||||
|
galleryBlock.id,
|
||||||
|
galleryBlock.galleryUrl,
|
||||||
|
galleryBlock.thumbnails,
|
||||||
|
galleryBlock.title,
|
||||||
|
galleryBlock.artists,
|
||||||
|
galleryBlock.series,
|
||||||
|
galleryBlock.type,
|
||||||
|
galleryBlock.language,
|
||||||
|
galleryBlock.relatedTags) },
|
||||||
|
old.reader?.galleryInfo,
|
||||||
|
old.imageList
|
||||||
|
)
|
||||||
|
|
||||||
|
fun copy(): Metadata = Metadata(galleryBlock, galleryInfo, imageList?.let { MutableList(it.size) { i -> it[i] } })
|
||||||
}
|
}
|
||||||
|
|
||||||
class Cache private constructor(context: Context, val galleryID: Int) : ContextWrapper(context) {
|
class Cache private constructor(context: Context, val galleryID: Int) : ContextWrapper(context) {
|
||||||
@@ -73,8 +112,12 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
|||||||
}
|
}
|
||||||
|
|
||||||
var metadata = kotlin.runCatching {
|
var metadata = kotlin.runCatching {
|
||||||
findFile(".metadata")?.readText()?.let {
|
findFile(".metadata")?.readText()?.let { metadata ->
|
||||||
Json.decodeFromString<Metadata>(it)
|
kotlin.runCatching {
|
||||||
|
Json.decodeFromString<Metadata>(metadata)
|
||||||
|
}.getOrElse {
|
||||||
|
Metadata(Json.decodeFromString<OldMetadata>(metadata))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.getOrNull() ?: Metadata()
|
}.getOrNull() ?: Metadata()
|
||||||
|
|
||||||
@@ -139,14 +182,14 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
|||||||
}.getOrNull()?.uri }
|
}.getOrNull()?.uri }
|
||||||
} } ?: Uri.EMPTY
|
} } ?: Uri.EMPTY
|
||||||
|
|
||||||
suspend fun getReader(): GalleryInfo? {
|
suspend fun getGalleryInfo(): GalleryInfo? {
|
||||||
|
|
||||||
return metadata.reader
|
return metadata.galleryInfo
|
||||||
?: withContext(Dispatchers.IO) {
|
?: withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
xyz.quaver.hitomi.getGalleryInfo(galleryID).also {
|
xyz.quaver.hitomi.getGalleryInfo(galleryID).also {
|
||||||
setMetadata { metadata ->
|
setMetadata { metadata ->
|
||||||
metadata.reader = it
|
metadata.galleryInfo = it
|
||||||
|
|
||||||
if (metadata.imageList == null)
|
if (metadata.imageList == null)
|
||||||
metadata.imageList = MutableList(it.files.size) { null }
|
metadata.imageList = MutableList(it.files.size) { null }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
classpath 'com.android.tools.build:gradle:4.2.2'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
@@ -25,7 +25,7 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url "https://guardian.github.com/maven/repo-releases" }
|
maven { url "https://guardian.github.io/maven/repo-releases/" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user