mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 07:57:30 +00:00
Implement BackgroundPollWorker
This commit is contained in:
parent
8651f20c9b
commit
2329e9d03d
@ -6,6 +6,7 @@ buildscript {
|
||||
ext.gradle_version = "3.4.1"
|
||||
ext.kotlin_version = "1.3.31"
|
||||
ext.kovenant_version = "3.3.0"
|
||||
ext.work_manager_version = "2.1.0"
|
||||
|
||||
repositories {
|
||||
google()
|
||||
@ -179,6 +180,7 @@ dependencies {
|
||||
implementation "com.squareup.okhttp3:okhttp:3.12.1"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "nl.komponents.kovenant:kovenant:$kovenant_version"
|
||||
implementation "androidx.work:work-runtime-ktx:$work_manager_version"
|
||||
}
|
||||
|
||||
android {
|
||||
|
20
src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt
Normal file
20
src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package org.thoughtcrime.securesms.loki
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPI
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPIDatabaseProtocol
|
||||
|
||||
class BackgroundPollWorker(private val userHexEncodedPublicKey: String, private val apiDatabase: LokiAPIDatabaseProtocol, context: Context, parameters: WorkerParameters) : Worker(context, parameters) {
|
||||
|
||||
override fun doWork(): Result {
|
||||
return try {
|
||||
LokiAPI(userHexEncodedPublicKey, apiDatabase).getMessages().get()
|
||||
// TODO: Process envelopes
|
||||
Result.success()
|
||||
} catch (exception: Exception) {
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user