androidx.lifecycle.AndroidViewModel Java Examples

The following examples show how to use androidx.lifecycle.AndroidViewModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: CloudReader   Author: youlookwhat   File:    License: Apache License 2.0 5 votes vote down vote up
 * 获取泛型ViewModel的class对象
public static <T> Class<T> getViewModel(Object obj) {
    Class<?> currentClass = obj.getClass();
    Class<T> tClass = getGenericClass(currentClass, AndroidViewModel.class);
    if (tClass == null || tClass == AndroidViewModel.class || tClass == NoViewModel.class) {
        return null;
    return tClass;