From f2e11bb69a8134eff325f900f862a639a358818e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 30 Jan 2020 20:49:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/ViewModelKt.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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