1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 19:16:07 -06:00

Bump hilt-work from 1.0.0-alpha02 to 1.0.0-alpha03 (#1099)

This commit is contained in:
dependabot-preview[bot] 2021-01-29 21:24:30 +00:00 committed by GitHub
parent d79b1c9a58
commit 6568c4abf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

View File

@ -131,6 +131,7 @@ play {
ext {
work_manager = "2.5.0"
work_hilt = "1.0.0-alpha03"
room = "2.3.0-alpha04"
chucker = "3.4.0"
mockk = "1.10.5"
@ -175,8 +176,8 @@ dependencies {
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'androidx.hilt:hilt-work:1.0.0-alpha02'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
implementation "androidx.hilt:hilt-work:$work_hilt"
kapt "androidx.hilt:hilt-compiler:$work_hilt"
implementation "com.aurelhubert:ahbottomnavigation:2.3.4"
implementation "com.ncapdevi:frag-nav:3.3.0"

View File

@ -5,11 +5,12 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.BigTextStyle
import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT
import androidx.core.app.NotificationManagerCompat
import androidx.hilt.Assisted
import androidx.hilt.work.WorkerInject
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.Data
import androidx.work.WorkerParameters
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import io.github.wulkanowy.R
import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.data.repositories.SemesterRepository
@ -23,7 +24,8 @@ import kotlinx.coroutines.coroutineScope
import timber.log.Timber
import kotlin.random.Random
class SyncWorker @WorkerInject constructor(
@HiltWorker
class SyncWorker @AssistedInject constructor(
@Assisted appContext: Context,
@Assisted workerParameters: WorkerParameters,
private val studentRepository: StudentRepository,
@ -58,9 +60,10 @@ class SyncWorker @WorkerInject constructor(
}
val result = when {
exceptions.isNotEmpty() && inputData.getBoolean("one_time", false) -> {
Result.failure(Data.Builder()
.putString("error", exceptions.map { it.stackTraceToString() }.toString())
.build()
Result.failure(
Data.Builder()
.putString("error", exceptions.map { it.stackTraceToString() }.toString())
.build()
)
}
exceptions.isNotEmpty() -> Result.retry()
@ -74,13 +77,16 @@ class SyncWorker @WorkerInject constructor(
}
private fun notify(result: Result) {
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(applicationContext, DebugChannel.CHANNEL_ID)
.setContentTitle("Debug notification")
.setSmallIcon(R.drawable.ic_stat_push)
.setAutoCancel(true)
.setColor(applicationContext.getCompatColor(R.color.colorPrimary))
.setStyle(BigTextStyle().bigText("${SyncWorker::class.java.simpleName} result: $result"))
.setPriority(PRIORITY_DEFAULT)
.build())
notificationManager.notify(
Random.nextInt(Int.MAX_VALUE),
NotificationCompat.Builder(applicationContext, DebugChannel.CHANNEL_ID)
.setContentTitle("Debug notification")
.setSmallIcon(R.drawable.ic_stat_push)
.setAutoCancel(true)
.setColor(applicationContext.getCompatColor(R.color.colorPrimary))
.setStyle(BigTextStyle().bigText("${SyncWorker::class.java.simpleName} result: $result"))
.setPriority(PRIORITY_DEFAULT)
.build()
)
}
}