Fix unnecessary calendar icon updates

This commit is contained in:
MM20 2024-05-12 18:30:01 +02:00
parent 90de026e49
commit e41d20331f
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -8,6 +8,7 @@ import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.RectF
import android.graphics.drawable.AdaptiveIconDrawable
import android.util.Log
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateFloatAsState
@ -87,6 +88,7 @@ import de.mm20.launcher2.ui.modifier.scale
import kotlinx.coroutines.launch
import palettes.TonalPalette
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
import kotlin.math.abs
import kotlin.math.pow
@ -133,9 +135,9 @@ fun ShapedLauncherIcon(
}
if (_icon is DynamicLauncherIcon) {
val time = LocalTime.current
LaunchedEffect(time, _icon) {
currentIcon = _icon.getIcon(time)
val date = Instant.ofEpochMilli(LocalTime.current).atZone(ZoneId.systemDefault())
LaunchedEffect(date.dayOfYear, _icon) {
currentIcon = _icon.getIcon(date.toEpochSecond() * 1000L)
}
}