android-lifecycle

Some fragment observers trigger after pop from back stack although data is not changed

谁说我不能喝 提交于 2020-05-21 07:25:08
问题 I have some problem in nested fragment in Kotlin. I have nested fragment with ViewModel. After resuming fragment from back button press all observers on viewModel LiveData triggers again although my data does not changed. First i googled and tried for define observer in filed variable and check if it is initialized then do not observer it again: lateinit var observer: Observer fun method(){ if (::observer.isInitialized) return observer = Observer{ ... } viewModel.x_live_data.observe

How to dynamically set the bundle from AbstractSavedStateViewModelFactory

丶灬走出姿态 提交于 2020-05-13 13:38:02
问题 My ViewModelFactory : class ViewModelFactory @Inject constructor( private val viewModelMap: MutableMap<Class<out ViewModel>, ViewModelAssistedFactory<out ViewModel>>, owner: SavedStateRegistryOwner, defaultArgs: Bundle? ) : AbstractSavedStateViewModelFactory(owner, defaultArgs) { @Throws(IllegalStateException::class) @Suppress("UNCHECKED_CAST") override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T { return viewModelMap[modelClass]?.create(handle)

How to dynamically set the bundle from AbstractSavedStateViewModelFactory

余生长醉 提交于 2020-05-13 13:36:05
问题 My ViewModelFactory : class ViewModelFactory @Inject constructor( private val viewModelMap: MutableMap<Class<out ViewModel>, ViewModelAssistedFactory<out ViewModel>>, owner: SavedStateRegistryOwner, defaultArgs: Bundle? ) : AbstractSavedStateViewModelFactory(owner, defaultArgs) { @Throws(IllegalStateException::class) @Suppress("UNCHECKED_CAST") override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T { return viewModelMap[modelClass]?.create(handle)

Activity life cycle methods : onPostResume significance

依然范特西╮ 提交于 2020-05-09 19:32:23
问题 Official documentation about Activity lists out 7 life cycle methods. onPostResume() was not quoted as life cycle method. But I feel that this method is important method. During the life cycle, when an activity is visible from hidden to show state, onRestart() onStart() onResume() onPostResume() have been invoked in order. My code snippet: package ravindra.projects.my_app_1; import android.content.Intent; import android.content.IntentFilter; import android.os.PersistableBundle; import android

Some fragment observers trigger after pop from back stack although data is not changed

假装没事ソ 提交于 2020-04-17 21:34:19
问题 I have some problem in nested fragment in Kotlin. I have nested fragment with ViewModel. After resuming fragment from back button press all observers on viewModel LiveData triggers again although my data does not changed. First i googled and tried for define observer in filed variable and check if it is initialized then do not observer it again: lateinit var observer: Observer fun method(){ if (::observer.isInitialized) return observer = Observer{ ... } viewModel.x_live_data.observe

Some fragment observers trigger after pop from back stack although data is not changed

£可爱£侵袭症+ 提交于 2020-04-17 21:32:52
问题 I have some problem in nested fragment in Kotlin. I have nested fragment with ViewModel. After resuming fragment from back button press all observers on viewModel LiveData triggers again although my data does not changed. First i googled and tried for define observer in filed variable and check if it is initialized then do not observer it again: lateinit var observer: Observer fun method(){ if (::observer.isInitialized) return observer = Observer{ ... } viewModel.x_live_data.observe

How to get rid of Incremental annotation processing requested warning?

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-12 07:00:11
问题 I have just started using android development and trying to use Room library. Since yesterday I am facing this warning message w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.lifecycle.LifecycleProcessor (NON_INCREMENTAL), androidx.room.RoomProcessor (NON_INCREMENTAL). I have tried to research and fix but unable to avoid this error here is my grale.build file. please suggest/advice what I am doing

Activity is closed after onActivityResult is called

做~自己de王妃 提交于 2020-02-06 05:43:09
问题 Activity Explanation: Activity_A ... nfc activity that gets started when tag is read Activity_B ... activity to capture user signature Hi, my problem goes like that: I have Activity_A and in that activity I call Activity_B with startActivityForResult() method. I then do some work in Activity_B and close it. After that method onActivityResult() is called in my Activity_A. I handle the returned data and all is great, but Activity_A is no longer visible. If I close Activity_B with back button,

java.lang.IllegalStateException: attempt to re-open an already-closed object On Orientation Change

ε祈祈猫儿з 提交于 2020-01-30 08:31:58
问题 I am using 1 Activity that inflates 2 fragments (2 panes) in case of sw600-land and 1 fragment case of sw600 both of the fragments implements LoaderManager.LoaderCallbacks I'm initializing loader by (in onStart ) getActivity().getSupportLoaderManager().initLoader(pm2_MAIN_LOADER_ID, null, this); then I closed the cursor in onLoadFinished (at the last line of it) giving me the error so I have tried to close it somewhere else as the answers that I found on StackOverflow as onDestroy giving the

Android Fragment onCreateView vs. onActivityCreated

喜夏-厌秋 提交于 2020-01-26 21:56:49
问题 I know that a fragment's view hierarchy has to be inflated in onCreateView, but what other functionality can be in onCreateView vs. what should wait for onActivityCreated? My current implementation uses separate activities for everything, and a typical activity does most of its work in its onCreate method, including inflating the view, setting the content view, initializing the various widgets with data, setting up listeners, etc. So can this probably all be moved into onCreateView, or should