@Test public void localViewModel() throws Throwable { class VM extends ViewModel1 { } try { mViewModelProvider.get(VM.class); Assert.fail(); } catch (IllegalArgumentException ignored) { } }
@NonNull @MainThread public <T extends ViewModel> T get(@NonNull Class<T> modelClass) { String canonicalName = modelClass.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return get(DEFAULT_KEY + ":" + canonicalName, modelClass); }
ViewModelProvider { @NonNull @MainThread public <T extends ViewModel> T get(@NonNull Class<T> modelClass) { String canonicalName = modelClass.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return get(DEFAULT_KEY + ":" + canonicalName, modelClass); } }
ViewModelProvider { @NonNull @MainThread public <T extends ViewModel> T get(@NonNull Class<T> modelClass) { String canonicalName = modelClass.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return get(DEFAULT_KEY + ":" + canonicalName, modelClass); } ViewModelProvider(@NonNull ViewModelStoreOwner owner, @NonNull Factory factory);  ViewModelProvider(@NonNull ViewModelStore store, @NonNull Factory factory); }
ViewModelProvider { @NonNull @MainThread public <T extends ViewModel> T get(@NonNull Class<T> modelClass) { String canonicalName = modelClass.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return get(DEFAULT_KEY + ":" + canonicalName, modelClass); } ViewModelProvider(@NonNull ViewModelStoreOwner owner, @NonNull Factory factory);  ViewModelProvider(@NonNull ViewModelStore store, @NonNull Factory factory); @NonNull @MainThread T get(@NonNull Class<T> modelClass); @NonNull @MainThread T get(@NonNull String key, @NonNull Class<T> modelClass); }
ViewModelProvider { @NonNull @MainThread public <T extends ViewModel> T get(@NonNull Class<T> modelClass) { String canonicalName = modelClass.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return get(DEFAULT_KEY + ":" + canonicalName, modelClass); } ViewModelProvider(@NonNull ViewModelStoreOwner owner, @NonNull Factory factory);  ViewModelProvider(@NonNull ViewModelStore store, @NonNull Factory factory); @NonNull @MainThread T get(@NonNull Class<T> modelClass); @NonNull @MainThread T get(@NonNull String key, @NonNull Class<T> modelClass);  }