Skip to content

Commit f6a2289

Browse files
committed
Work version 1.0.0-alpha12 onwards - the doWork() function now returns Result instead of Payload.
1 parent e1949a6 commit f6a2289

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ dependencies {
9292
kapt "androidx.room:room-compiler:$version_room"
9393

9494
// Kotlin Extensions and Coroutines support for Room
95-
implementation "androidx.room:room-ktx:$room_version"
95+
implementation "androidx.room:room-ktx:$version_room"
9696

9797
// WorkManager
9898
implementation "android.arch.work:work-runtime-ktx:$version_work"

app/src/main/java/com/example/android/devbyteviewer/work/RefreshDataWork.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ class RefreshDataWorker(appContext: Context, params: WorkerParameters):
3333

3434
/**
3535
* A coroutine-friendly method to do your work.
36+
* Note: In recent work version upgrade, 1.0.0-alpha12 and onwards have a breaking change.
37+
* The doWork() function now returns Result instead of Payload because they have combined Payload into Result.
38+
* Read more here - https://developer.android.com/jetpack/androidx/releases/work#1.0.0-alpha12
3639
*/
37-
override suspend fun doWork(): Payload {
40+
override suspend fun doWork(): Result {
3841
val database = getDatabase(applicationContext)
3942
val repository = VideosRepository(database)
4043
return try {
4144
repository.refreshVideos()
42-
Payload(Result.SUCCESS)
45+
Result.success()
4346
} catch (e: HttpException) {
44-
Payload(Result.RETRY)
47+
Result.retry()
4548
}
4649
}
4750
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ buildscript {
3636
version_moshi = "1.8.0"
3737
version_glide = "4.8.0"
3838
version_joda = "2.10"
39-
version_work = "1.0.0-alpha11"
39+
version_work = "1.0.1"
4040
version_timber = "4.7.1"
4141
}
4242

0 commit comments

Comments
 (0)