diff --git a/README.md b/README.md index ae7a9eda8..312ae76a6 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Libraries Used * [Layout][35] - Lay out widgets using different algorithms. * Third party * [Glide][90] for image loading - * [Kotlin Coroutines][91] for async jobs, plays the role like light-weight threads. + * [Kotlin Coroutines][91] for managing background threads with simplified code and reducing needs for callbacks [0]: https://developer.android.com/jetpack/foundation/ [1]: https://developer.android.com/topic/libraries/support-library/packages#v7-appcompat @@ -84,7 +84,7 @@ Libraries Used [34]: https://developer.android.com/guide/components/fragments [35]: https://developer.android.com/guide/topics/ui/declaring-layout [90]: https://bumptech.github.io/glide/ -[91]: https://github.com/Kotlin/kotlinx.coroutines +[91]: https://kotlinlang.org/docs/reference/coroutines-overview.html Upcoming features ----------------- diff --git a/app/build.gradle b/app/build.gradle index efdd18635..2f9f91cb7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,8 +63,8 @@ dependencies { implementation "com.google.android.material:material:$rootProject.supportLibraryVersion" implementation "com.google.code.gson:gson:$rootProject.gsonVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlinVersion" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutinesVersion" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutinesVersion" // Testing dependencies androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion" diff --git a/app/src/main/java/com/google/samples/apps/sunflower/viewmodels/ScopedViewModel.kt b/app/src/main/java/com/google/samples/apps/sunflower/viewmodels/ScopedViewModel.kt deleted file mode 100644 index e3e271f17..000000000 --- a/app/src/main/java/com/google/samples/apps/sunflower/viewmodels/ScopedViewModel.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.sunflower.viewmodels - -import androidx.lifecycle.ViewModel -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlin.coroutines.CoroutineContext - -abstract class ScopedViewModel : ViewModel(), CoroutineScope { - private val job = Job() - - override val coroutineContext: CoroutineContext - get() = Dispatchers.Main + job - - override fun onCleared() { - job.cancel() - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 039fe669a..e8ee53c4e 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ buildscript { // App dependencies constraintLayoutVersion = '2.0.0-alpha2' coreTestingVersion = '2.0.0' - coroutines = "1.0.1" + coroutinesVersion = "1.0.1" espressoVersion = '3.1.0-alpha4' glideVersion = '4.8.0' gradleVersion = '3.2.1'