diff --git a/app/build.gradle b/app/build.gradle index 01b76c377..8afa5280c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -185,7 +185,7 @@ dependencies { implementation 'androidx.core:core-splashscreen:1.0.0-alpha02' implementation "androidx.activity:activity-ktx:1.4.0" implementation "androidx.appcompat:appcompat:1.4.0-rc01" - implementation "androidx.fragment:fragment-ktx:1.3.6" + implementation "androidx.fragment:fragment-ktx:1.4.0-rc01" implementation "androidx.annotation:annotation:1.3.0" implementation "androidx.preference:preference-ktx:1.1.1" diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt index 4621c5928..70d91f9a1 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt @@ -6,7 +6,6 @@ import android.util.Log.DEBUG import android.util.Log.INFO import android.util.Log.VERBOSE import android.webkit.WebView -import androidx.fragment.app.FragmentManager import androidx.hilt.work.HiltWorkerFactory import androidx.work.Configuration import com.yariksoffice.lingver.Lingver @@ -44,7 +43,6 @@ class WulkanowyApp : Application(), Configuration.Provider { @SuppressLint("UnsafeOptInUsageWarning") override fun onCreate() { super.onCreate() - FragmentManager.enableNewStateManager(false) initializeAppLanguage() themeManager.applyDefaultTheme() initLogging() diff --git a/app/src/main/java/io/github/wulkanowy/utils/LifecycleAwareVariable.kt b/app/src/main/java/io/github/wulkanowy/utils/LifecycleAwareVariable.kt index d2a8908ce..032e2d28a 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/LifecycleAwareVariable.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/LifecycleAwareVariable.kt @@ -4,13 +4,12 @@ import android.os.Handler import android.os.Looper import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleObserver -import androidx.lifecycle.OnLifecycleEvent +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -class LifecycleAwareVariable : ReadWriteProperty, LifecycleObserver { +class LifecycleAwareVariable : ReadWriteProperty, DefaultLifecycleObserver { private var _value: T? = null @@ -23,15 +22,15 @@ class LifecycleAwareVariable : ReadWriteProperty, Lifecycl override fun getValue(thisRef: Fragment, property: KProperty<*>) = _value ?: throw IllegalStateException("Trying to call an lifecycle-aware value outside of the view lifecycle, or the value has not been initialized") - @Suppress("unused") - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - fun onDestroyView() { - _value = null + override fun onDestroy(owner: LifecycleOwner) { + Handler(Looper.getMainLooper()).post { + _value = null + } } } class LifecycleAwareVariableActivity : ReadWriteProperty, - LifecycleObserver { + DefaultLifecycleObserver { private var _value: T? = null @@ -44,9 +43,7 @@ class LifecycleAwareVariableActivity : ReadWriteProperty) = _value ?: throw IllegalStateException("Trying to call an lifecycle-aware value outside of the view lifecycle, or the value has not been initialized") - @Suppress("unused") - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - fun onDestroyView() { + override fun onDestroy(owner: LifecycleOwner) { Handler(Looper.getMainLooper()).post { _value = null }