Skip to content

Commit

Permalink
Moved service initialization to Compose
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora Gras <[email protected]>
  • Loading branch information
ArnyminerZ committed Mar 25, 2024
1 parent fa00a11 commit a78505a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ import at.bitfire.icsdroid.ui.partials.CalendarListItem
import at.bitfire.icsdroid.ui.partials.ExtendedTopAppBar
import at.bitfire.icsdroid.ui.partials.SyncIntervalDialog
import at.bitfire.icsdroid.ui.theme.setContentThemed
import java.util.ServiceLoader
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.ServiceLoader

@OptIn(ExperimentalFoundationApi::class)
class CalendarListActivity: AppCompatActivity() {
Expand Down Expand Up @@ -124,11 +124,12 @@ class CalendarListActivity: AppCompatActivity() {
if (requestPermissions && !PermissionUtils.haveCalendarPermissions(this))
requestCalendarPermissions()

// Init and collect all ComposableStartupServices
val compStartupServices = ServiceLoader.load(ComposableStartupService::class.java)
.onEach { it.initialize(this) }

setContentThemed {
// Init and collect all ComposableStartupServices
val compStartupServices = remember {
ServiceLoader.load(ComposableStartupService::class.java)
.onEach { it.initialize(this) }
}
compStartupServices.forEach { service ->
val show: Boolean by service.shouldShow().observeAsState(false)
if (show) service.Content()
Expand Down

0 comments on commit a78505a

Please sign in to comment.