From 4c1da1bd1daa9ce51778546021de727c17ef65ba Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 31 Aug 2022 15:56:08 -0400 Subject: [PATCH] Maybe fix extensions list crash Also fix weird animation of last updated text in Updates --- app/build.gradle.kts | 2 +- .../presentation/updates/UpdatesScreen.kt | 5 ++- .../presentation/updates/UpdatesUiItem.kt | 32 ++++++++++--------- .../browse/extension/ExtensionsPresenter.kt | 8 ++--- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5da0567618..d7c9886dc9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -288,7 +288,7 @@ tasks { } withType().configureEach { - exclude { it.file.path.contains("generated[\\\\/]".toRegex())} + exclude { it.file.path.contains("generated[\\\\/]".toRegex()) } } // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index f965463af4..ad1ae7111f 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -164,10 +164,9 @@ fun UpdateScreen( contentPadding = contentPaddingWithNavBar, ) { if (presenter.lastUpdated > 0L) { - item(key = "last_updated") { - UpdatesLastUpdatedItem(presenter.lastUpdated) - } + updatesLastUpdatedItem(presenter.lastUpdated) } + updatesUiItems( uiModels = presenter.uiModels, selectionMode = presenter.selectionMode, diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt index a9f1abfc92..0ca5d7d5f8 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt @@ -49,24 +49,26 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem import java.text.DateFormat import java.util.Date -@Composable -fun UpdatesLastUpdatedItem( +fun LazyListScope.updatesLastUpdatedItem( lastUpdated: Long, ) { - val time = remember(lastUpdated) { - DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS) - } + item(key = "last_updated") { + val time = remember(lastUpdated) { + DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS) + } - Box( - modifier = Modifier - .padding(horizontal = horizontalPadding, vertical = 8.dp), - ) { - Text( - text = stringResource(R.string.updates_last_update_info, time), - style = LocalTextStyle.current.copy( - fontStyle = FontStyle.Italic, - ), - ) + Box( + modifier = Modifier + .animateItemPlacement() + .padding(horizontal = horizontalPadding, vertical = 8.dp), + ) { + Text( + text = stringResource(R.string.updates_last_update_info, time), + style = LocalTextStyle.current.copy( + fontStyle = FontStyle.Italic, + ), + ) + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt index e270d4dc2b..b75967c62b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt @@ -202,16 +202,16 @@ sealed interface ExtensionUiModel { data class Resource(@StringRes val textRes: Int) : Header data class Text(val text: String) : Header } + data class Item( val extension: Extension, val installStep: InstallStep, ) : ExtensionUiModel { fun key(): String { - return when (extension) { - is Extension.Installed -> - if (extension.hasUpdate) "update_${extension.pkgName}" else extension.pkgName - else -> extension.pkgName + return when { + extension is Extension.Installed && extension.hasUpdate -> "${extension.pkgName}_update" + else -> "${extension.pkgName}_${installStep.name}" } } }