mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Catch exceptions when providing widget layout
possible fix widget being stuck on initial layout
This commit is contained in:
parent
aa89e16bbb
commit
16bb8b5709
@ -19,6 +19,7 @@
|
|||||||
package com.sadellie.unitto.feature.glance.glance
|
package com.sadellie.unitto.feature.glance.glance
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.ui.unit.TextUnit
|
import androidx.compose.ui.unit.TextUnit
|
||||||
@ -86,9 +87,12 @@ class CalculatorWidget : GlanceAppWidget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun provideGlance(context: Context, id: GlanceId) {
|
override suspend fun provideGlance(context: Context, id: GlanceId) {
|
||||||
|
val userPrefsRepository = try {
|
||||||
val userPrefsRepository =
|
|
||||||
EntryPoints.get(context, UserPrefEntryPoint::class.java).userPrefRep()
|
EntryPoints.get(context, UserPrefEntryPoint::class.java).userPrefRep()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("CalculatorWidget", "Error: $e")
|
||||||
|
provideContent { LoadingUI() } // everything after is unreachable, no need for return
|
||||||
|
}
|
||||||
|
|
||||||
provideContent {
|
provideContent {
|
||||||
val appPrefs = userPrefsRepository.calculatorPrefs.collectAsState(initial = null).value
|
val appPrefs = userPrefsRepository.calculatorPrefs.collectAsState(initial = null).value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user