This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Activity { | |
| // Code | |
| public Object onRetainNonConfigurationInstance() { | |
| return null; | |
| } | |
| // Code | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FragmentActivity { | |
| @Override | |
| @Nullable | |
| public final Object onRetainNonConfigurationInstance() { | |
| // Code | |
| NonConfigurationInstances nci = new NonConfigurationInstances(); | |
| // Code | |
| nci.viewModelStore = mViewModelStore; | |
| return nci; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FragmentActivity { | |
| // Code | |
| public Object getLastCustomNonConfigurationInstance() { | |
| NonConfigurationInstances nc = (NonConfigurationInstances) | |
| getLastNonConfigurationInstance(); | |
| return nc != null ? nc.custom : null; | |
| } | |
| public Object onRetainCustomNonConfigurationInstance() { | |
| return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Fragment { | |
| // Code | |
| public ViewModelStore getViewModelStore() { | |
| // Code | |
| if (mViewModelStore == null) { | |
| mViewModelStore = new ViewModelStore(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final Object onRetainNonConfigurationInstance() { | |
| // Code | |
| FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig(); | |
| // Code | |
| NonConfigurationInstances nci = new NonConfigurationInstances(); | |
| nci.custom = custom; | |
| nci.viewModelStore = mViewModelStore; | |
| nci.fragments = fragments; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final class FragmentState implements Parcelable { | |
| // Code | |
| public Fragment instantiate(FragmentHostCallback host, FragmentContainer container, | |
| Fragment parent, FragmentManagerNonConfig childNonConfig, | |
| ViewModelStore viewModelStore) { | |
| // Code, that initialize a new Fragment | |
| mInstance.mViewModelStore = viewModelStore; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class ViewModel { | |
| protected void onCleared() { // Code } | |
| final void clear() { // Code } | |
| <T> T setTagIfAbsent(String key, T newValue) { // Code } | |
| <T> T getTag(String key) { // Code } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Fragment { | |
| // Code | |
| public ViewModelStore getViewModelStore() { | |
| if (mFragmentManager == null) { | |
| throw new IllegalStateException(// Exception text); | |
| } | |
| return mFragmentManager.getViewModelStore(this); | |
| } | |
| // Code | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FragmentManagerImpl { | |
| // Code | |
| ViewModelStore getViewModelStore(@NonNull Fragment f) { | |
| return mNonConfig.getViewModelStore(f); | |
| } | |
| // Code | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final class FragmentManagerImpl extends FragmentManager implements LayoutInflater.Factory2 { | |
| // Code | |
| public void attachController(@NonNull FragmentHostCallback host, | |
| @NonNull FragmentContainer container, @Nullable final Fragment parent) { | |
| // Code | |
| if (parent != null) { | |
| // Code | |
| } else if (host instanceof ViewModelStoreOwner) { | |
| ViewModelStore viewModelStore = ((ViewModelStoreOwner) host).getViewModelStore(); | |
| mNonConfig = FragmentManagerViewModel.getInstance(viewModelStore); |