Maybe fix extensions list crash

Also fix weird animation of last updated text in Updates
This commit is contained in:
arkon 2022-08-31 15:56:08 -04:00
parent dc62d0ea8b
commit 4c1da1bd1d
4 changed files with 24 additions and 23 deletions

View File

@ -288,7 +288,7 @@ tasks {
} }
withType<org.jmailen.gradle.kotlinter.tasks.LintTask>().configureEach { withType<org.jmailen.gradle.kotlinter.tasks.LintTask>().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) // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)

View File

@ -164,10 +164,9 @@ fun UpdateScreen(
contentPadding = contentPaddingWithNavBar, contentPadding = contentPaddingWithNavBar,
) { ) {
if (presenter.lastUpdated > 0L) { if (presenter.lastUpdated > 0L) {
item(key = "last_updated") { updatesLastUpdatedItem(presenter.lastUpdated)
UpdatesLastUpdatedItem(presenter.lastUpdated)
}
} }
updatesUiItems( updatesUiItems(
uiModels = presenter.uiModels, uiModels = presenter.uiModels,
selectionMode = presenter.selectionMode, selectionMode = presenter.selectionMode,

View File

@ -49,24 +49,26 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem
import java.text.DateFormat import java.text.DateFormat
import java.util.Date import java.util.Date
@Composable fun LazyListScope.updatesLastUpdatedItem(
fun UpdatesLastUpdatedItem(
lastUpdated: Long, lastUpdated: Long,
) { ) {
val time = remember(lastUpdated) { item(key = "last_updated") {
DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS) val time = remember(lastUpdated) {
} DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS)
}
Box( Box(
modifier = Modifier modifier = Modifier
.padding(horizontal = horizontalPadding, vertical = 8.dp), .animateItemPlacement()
) { .padding(horizontal = horizontalPadding, vertical = 8.dp),
Text( ) {
text = stringResource(R.string.updates_last_update_info, time), Text(
style = LocalTextStyle.current.copy( text = stringResource(R.string.updates_last_update_info, time),
fontStyle = FontStyle.Italic, style = LocalTextStyle.current.copy(
), fontStyle = FontStyle.Italic,
) ),
)
}
} }
} }

View File

@ -202,16 +202,16 @@ sealed interface ExtensionUiModel {
data class Resource(@StringRes val textRes: Int) : Header data class Resource(@StringRes val textRes: Int) : Header
data class Text(val text: String) : Header data class Text(val text: String) : Header
} }
data class Item( data class Item(
val extension: Extension, val extension: Extension,
val installStep: InstallStep, val installStep: InstallStep,
) : ExtensionUiModel { ) : ExtensionUiModel {
fun key(): String { fun key(): String {
return when (extension) { return when {
is Extension.Installed -> extension is Extension.Installed && extension.hasUpdate -> "${extension.pkgName}_update"
if (extension.hasUpdate) "update_${extension.pkgName}" else extension.pkgName else -> "${extension.pkgName}_${installStep.name}"
else -> extension.pkgName
} }
} }
} }