Use immutable collections in presentation-widget module
This commit is contained in:
parent
4a6571d310
commit
3c3b09209c
@ -56,7 +56,7 @@ import org.acra.ktx.initAcra
|
||||
import org.acra.sender.HttpSender
|
||||
import org.conscrypt.Conscrypt
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.presentation.widget.TachiyomiWidgetManager
|
||||
import tachiyomi.presentation.widget.WidgetManager
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -127,7 +127,7 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||
setAppCompatDelegateThemeMode(Injekt.get<UiPreferences>().themeMode().get())
|
||||
|
||||
// Updates widget update
|
||||
with(TachiyomiWidgetManager(Injekt.get(), Injekt.get())) {
|
||||
with(WidgetManager(Injekt.get(), Injekt.get())) {
|
||||
init(ProcessLifecycleOwner.get().lifecycleScope)
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ xml_serialization_version = "0.86.2"
|
||||
reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" }
|
||||
gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_version" }
|
||||
|
||||
immutables = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.6" }
|
||||
|
||||
coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version = "1.7.3" }
|
||||
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" }
|
||||
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" }
|
||||
|
@ -28,6 +28,8 @@ dependencies {
|
||||
implementation(compose.glance)
|
||||
lintChecks(compose.lintchecks)
|
||||
|
||||
implementation(kotlinx.immutables)
|
||||
|
||||
implementation(platform(libs.coil.bom))
|
||||
implementation(libs.coil.core)
|
||||
|
||||
|
@ -30,6 +30,8 @@ import coil.size.Scale
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.map
|
||||
import tachiyomi.core.util.lang.withIOContext
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
@ -106,7 +108,7 @@ abstract class BaseUpdatesGridGlanceWidget(
|
||||
private suspend fun List<UpdatesWithRelations>.prepareData(
|
||||
rowCount: Int,
|
||||
columnCount: Int,
|
||||
): List<Pair<Long, Bitmap?>> {
|
||||
): ImmutableList<Pair<Long, Bitmap?>> {
|
||||
// Resize to cover size
|
||||
val widthPx = CoverWidth.value.toInt().dpToPx
|
||||
val heightPx = CoverHeight.value.toInt().dpToPx
|
||||
@ -140,6 +142,7 @@ abstract class BaseUpdatesGridGlanceWidget(
|
||||
.build()
|
||||
Pair(updatesView.mangaId, context.imageLoader.executeBlocking(request).drawable?.toBitmap())
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.updates.interactor.GetUpdates
|
||||
|
||||
class TachiyomiWidgetManager(
|
||||
class WidgetManager(
|
||||
private val getUpdates: GetUpdates,
|
||||
private val securityPreferences: SecurityPreferences,
|
||||
) {
|
@ -21,6 +21,7 @@ import androidx.glance.layout.padding
|
||||
import androidx.glance.text.Text
|
||||
import androidx.glance.text.TextStyle
|
||||
import androidx.glance.unit.ColorProvider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import tachiyomi.core.Constants
|
||||
import tachiyomi.presentation.widget.R
|
||||
import tachiyomi.presentation.widget.util.calculateRowAndColumnCount
|
||||
@ -28,7 +29,7 @@ import tachiyomi.presentation.widget.util.stringResource
|
||||
|
||||
@Composable
|
||||
fun UpdatesWidget(
|
||||
data: List<Pair<Long, Bitmap?>>?,
|
||||
data: ImmutableList<Pair<Long, Bitmap?>>?,
|
||||
contentColor: ColorProvider,
|
||||
topPadding: Dp,
|
||||
bottomPadding: Dp,
|
||||
|
Loading…
Reference in New Issue
Block a user