From 906737400ddbed49f0616658f07af66777166341 Mon Sep 17 00:00:00 2001 From: tuancoltech Date: Tue, 5 Dec 2023 07:36:23 +0700 Subject: [PATCH] [bug] Fix crash in Android Navigator: https://github.com/ARK-Builders/ARK-Navigator/issues/412 --- app/build.gradle | 7 +++++-- .../navigator/data/stats/category/TagLabeledNStorage.kt | 9 +++++++-- .../gallery/previewpager/PreviewImageViewHolder.kt | 4 ++-- build.gradle | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7aa6dab4..b3cfffcb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,8 +109,11 @@ android { dependencies { //For local developments of arklib-android: - releaseImplementation "dev.arkbuilders:arklib:$ark_lib_version" - debugImplementation "dev.arkbuilders:arklib-debug:$ark_lib_version" + //def arklibVersion = '999' + def arklibVersion = '0.3.4-snapshot-crash-28' + +// releaseImplementation "dev.arkbuilders:arklib:$ark_lib_version" + debugImplementation "dev.arkbuilders:arklib-debug:$arklibVersion" implementation("dev.arkbuilders:components:$ark_components_version") { exclude group: "dev.arkbuilders", module: "arklib" } diff --git a/app/src/main/java/dev/arkbuilders/navigator/data/stats/category/TagLabeledNStorage.kt b/app/src/main/java/dev/arkbuilders/navigator/data/stats/category/TagLabeledNStorage.kt index 8ba67873..b5222248 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/data/stats/category/TagLabeledNStorage.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/data/stats/category/TagLabeledNStorage.kt @@ -27,8 +27,13 @@ class TagLabeledNStorage( override suspend fun init() { val storage = locateStorage() if (storage?.exists() == true) { - val json = Json.decodeFromStream(storage.inputStream()) - tagLabeledAmount.putAll(json.data) + try { + val json = Json.decodeFromStream(storage.inputStream()) + tagLabeledAmount.putAll(json.data) + } catch (exception: Exception) { + Timber.e("tuancoltech" + " TagLabeledNStorage.init exception: " + exception.message) + } + } else { index.allIds() .associateWith { tagsStorage.getTags(it) } diff --git a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt index 2e814869..107dda30 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt @@ -20,7 +20,7 @@ import dev.arkbuilders.arklib.ResourceId import dev.arkbuilders.arklib.data.meta.Metadata import dev.arkbuilders.arklib.data.preview.PreviewLocator import dev.arkbuilders.arklib.data.preview.PreviewStatus -import dev.arkbuilders.arklib.utils.ImageUtils.loadGlideZoomImage +import dev.arkbuilders.arklib.utils.ImageUtils.loadImage import dev.arkbuilders.arklib.utils.ImageUtils.loadSubsamplingImage import timber.log.Timber @@ -95,7 +95,7 @@ class PreviewImageViewHolder( } val path = locator.fullscreen() - loadGlideZoomImage(id, path, ivZoom) + loadImage(id, path, ivZoom, false) loadSubsamplingImage(path, ivSubsampling) } diff --git a/build.gradle b/build.gradle index d349ac62..665954cb 100644 --- a/build.gradle +++ b/build.gradle @@ -91,5 +91,6 @@ allprojects { maven { url "https://plugins.gradle.org/m2/" } gradlePluginPortal() maven { url 'https://jitpack.io' } + mavenLocal() } }