Created
July 5, 2017 08:26
-
-
Save AkshayChordiya/80fc62d271d41e99cf82cea617bb1194 to your computer and use it in GitHub Desktop.
ViewModelStore
This file contains 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 ViewModelStore { | |
private final HashMap<String, ViewModel> mMap = new HashMap(); | |
public ViewModelStore() {} | |
final void put(String key, ViewModel viewModel) { | |
ViewModel oldViewModel = (ViewModel)this.mMap.get(key); | |
if(oldViewModel != null) { | |
oldViewModel.onCleared(); | |
} | |
this.mMap.put(key, viewModel); | |
} | |
final ViewModel get(String key) { | |
return (ViewModel)this.mMap.get(key); | |
} | |
public final void clear() { | |
Iterator var1 = this.mMap.values().iterator(); | |
while(var1.hasNext()) { | |
ViewModel vm = (ViewModel)var1.next(); | |
vm.onCleared(); | |
} | |
this.mMap.clear(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment