Skip to content

Commit

Permalink
Add error message at attempt to get fragmentManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Nesterov committed Apr 18, 2024
1 parent f035e38 commit 3e50aac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ actual fun BindEffect(permissionsController: PermissionsController) {
val context: Context = LocalContext.current

LaunchedEffect(permissionsController, lifecycleOwner, context) {
val fragmentManager: FragmentManager = (context as FragmentActivity).supportFragmentManager
val fragmentManager: FragmentManager = checkNotNull(context as? FragmentActivity) {
"$context context is not instance of FragmentActivity"
}.supportFragmentManager

permissionsController.bind(lifecycleOwner.lifecycle, fragmentManager)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.icerockdev

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -27,7 +28,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.fragment.app.FragmentActivity
import com.icerockdev.library.SampleViewModel
import dev.icerock.moko.mvvm.dispatcher.eventsDispatcherOnMain
import dev.icerock.moko.mvvm.getViewModel
Expand All @@ -39,7 +39,7 @@ import dev.icerock.moko.permissions.PermissionsController
import dev.icerock.moko.permissions.compose.BindEffect
import kotlinx.coroutines.launch

class MainActivity : FragmentActivity() {
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand Down

0 comments on commit 3e50aac

Please sign in to comment.