From 21d8a14fedabba32e47dcdb70274ff6708ab3539 Mon Sep 17 00:00:00 2001 From: Sujin Date: Tue, 3 Dec 2019 09:58:02 +0545 Subject: [PATCH] Remove deprecated ViewModelProviders --- about/src/main/java/io/plaidapp/about/ui/AboutActivity.kt | 5 ++--- app/src/main/java/io/plaidapp/dagger/HomeModule.kt | 4 ++-- build.gradle | 2 +- .../java/io/plaidapp/designernews/dagger/StoryModule.kt | 6 +++--- .../main/java/io/plaidapp/dribbble/dagger/DribbbleModule.kt | 4 ++-- .../src/main/java/io/plaidapp/search/dagger/SearchModule.kt | 4 ++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/about/src/main/java/io/plaidapp/about/ui/AboutActivity.kt b/about/src/main/java/io/plaidapp/about/ui/AboutActivity.kt index 7bfff3b44..ab1c327b5 100644 --- a/about/src/main/java/io/plaidapp/about/ui/AboutActivity.kt +++ b/about/src/main/java/io/plaidapp/about/ui/AboutActivity.kt @@ -22,7 +22,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.browser.customtabs.CustomTabsIntent import androidx.core.content.ContextCompat import androidx.core.net.toUri -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import io.plaidapp.about.R import io.plaidapp.about.dagger.inject import io.plaidapp.about.databinding.ActivityAboutBinding @@ -57,8 +57,7 @@ class AboutActivity : AppCompatActivity() { inject() - val viewModel = ViewModelProviders - .of(this, aboutViewModelFactory) + val viewModel = ViewModelProvider(this, aboutViewModelFactory) .get(AboutViewModel::class.java) .apply { navigationTarget.observe(this@AboutActivity, EventObserver { url -> diff --git a/app/src/main/java/io/plaidapp/dagger/HomeModule.kt b/app/src/main/java/io/plaidapp/dagger/HomeModule.kt index 724f7ad2c..0344fe96c 100644 --- a/app/src/main/java/io/plaidapp/dagger/HomeModule.kt +++ b/app/src/main/java/io/plaidapp/dagger/HomeModule.kt @@ -21,7 +21,7 @@ import android.content.Context import android.net.ConnectivityManager import androidx.core.content.getSystemService import androidx.fragment.app.FragmentActivity -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import dagger.Binds import dagger.Module import dagger.Provides @@ -75,7 +75,7 @@ abstract class HomeModule { factory: HomeViewModelFactory, fragmentActivity: FragmentActivity ): HomeViewModel { - return ViewModelProviders.of(fragmentActivity, factory).get(HomeViewModel::class.java) + return ViewModelProvider(fragmentActivity, factory).get(HomeViewModel::class.java) } @JvmStatic diff --git a/build.gradle b/build.gradle index b9a54f926..99316e268 100644 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,7 @@ buildscript { scriptHandler -> ] dependencies { - classpath 'com.android.tools.build:gradle:3.6.0-beta03' + classpath 'com.android.tools.build:gradle:3.6.0-beta04' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" classpath "com.google.gms:google-services:${versions.googleServices}" classpath "io.fabric.tools:gradle:${versions.fabric}" diff --git a/designernews/src/main/java/io/plaidapp/designernews/dagger/StoryModule.kt b/designernews/src/main/java/io/plaidapp/designernews/dagger/StoryModule.kt index a88b3e049..c94983238 100644 --- a/designernews/src/main/java/io/plaidapp/designernews/dagger/StoryModule.kt +++ b/designernews/src/main/java/io/plaidapp/designernews/dagger/StoryModule.kt @@ -16,7 +16,7 @@ package io.plaidapp.designernews.dagger -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import dagger.Module import dagger.Provides import io.plaidapp.core.dagger.scope.FeatureScope @@ -46,13 +46,13 @@ class StoryModule(private val storyId: Long, private val activity: StoryActivity fun provideLoginViewModel( factory: DesignerNewsViewModelFactory ): LoginViewModel = - ViewModelProviders.of(activity, factory).get(LoginViewModel::class.java) + ViewModelProvider(activity, factory).get(LoginViewModel::class.java) @Provides fun provideStoryViewModel( factory: StoryViewModelFactory ): StoryViewModel = - ViewModelProviders.of(activity, factory).get(StoryViewModel::class.java) + ViewModelProvider(activity, factory).get(StoryViewModel::class.java) @Provides fun provideStoryViewModelFactory( diff --git a/dribbble/src/main/java/io/plaidapp/dribbble/dagger/DribbbleModule.kt b/dribbble/src/main/java/io/plaidapp/dribbble/dagger/DribbbleModule.kt index f4972cf98..e1357bf5f 100644 --- a/dribbble/src/main/java/io/plaidapp/dribbble/dagger/DribbbleModule.kt +++ b/dribbble/src/main/java/io/plaidapp/dribbble/dagger/DribbbleModule.kt @@ -16,8 +16,8 @@ package io.plaidapp.dribbble.dagger -import androidx.lifecycle.ViewModelProviders import android.content.Context +import androidx.lifecycle.ViewModelProvider import dagger.Module import dagger.Provides import io.plaidapp.core.data.CoroutinesDispatcherProvider @@ -42,7 +42,7 @@ class DribbbleModule(private val activity: ShotActivity, private val shotId: Lon @Provides fun shotViewModel(factory: ShotViewModelFactory): ShotViewModel { - return ViewModelProviders.of(activity, factory).get(ShotViewModel::class.java) + return ViewModelProvider(activity, factory).get(ShotViewModel::class.java) } @Provides diff --git a/search/src/main/java/io/plaidapp/search/dagger/SearchModule.kt b/search/src/main/java/io/plaidapp/search/dagger/SearchModule.kt index ad78def4f..4b81d7d67 100644 --- a/search/src/main/java/io/plaidapp/search/dagger/SearchModule.kt +++ b/search/src/main/java/io/plaidapp/search/dagger/SearchModule.kt @@ -19,7 +19,7 @@ package io.plaidapp.search.dagger import android.app.Activity import android.content.Context import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import dagger.Binds import dagger.Module import dagger.Provides @@ -96,7 +96,7 @@ abstract class SearchModule { factory: SearchViewModelFactory, activity: AppCompatActivity ): SearchViewModel { - return ViewModelProviders.of(activity, factory).get(SearchViewModel::class.java) + return ViewModelProvider(activity, factory).get(SearchViewModel::class.java) } } }