diff --git a/app/src/main/java/io/legado/app/utils/ViewModelKt.kt b/app/src/main/java/io/legado/app/utils/ViewModelKt.kt index b777c8bbf..0b76009cf 100644 --- a/app/src/main/java/io/legado/app/utils/ViewModelKt.kt +++ b/app/src/main/java/io/legado/app/utils/ViewModelKt.kt @@ -3,14 +3,15 @@ package io.legado.app.utils import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider -fun AppCompatActivity.getViewModel(clazz: Class) = ViewModelProviders.of(this).get(clazz) +fun AppCompatActivity.getViewModel(clazz: Class) = + ViewModelProvider(this).get(clazz) -fun Fragment.getViewModel(clazz: Class) = ViewModelProviders.of(this).get(clazz) +fun Fragment.getViewModel(clazz: Class) = ViewModelProvider(this).get(clazz) /** * 与activity数据同步 */ fun Fragment.getViewModelOfActivity(clazz: Class) = - ViewModelProviders.of(requireActivity()).get(clazz) \ No newline at end of file + ViewModelProvider(requireActivity()).get(clazz) \ No newline at end of file