SyncWorker

class SyncWorker @AssistedInject constructor(@Assisted appContext: Context, @Assisted workerParams: WorkerParameters, coroutineDispatcherProvider: CoroutineDispatcherProvider, notificationConfigurationProvider: NotificationConfigurationProvider, changeListVersionRepository: ChangeListVersionRepository, syncables: Array<Syncable>) : CoroutineWorker, Synchronizer

Syncs the data layer by delegating to the appropriate repository instances with sync functionality.

Constructors

Link copied to clipboard
@AssistedInject
constructor(@Assisted appContext: Context, @Assisted workerParams: WorkerParameters, coroutineDispatcherProvider: CoroutineDispatcherProvider, notificationConfigurationProvider: NotificationConfigurationProvider, changeListVersionRepository: ChangeListVersionRepository, syncables: Array<Syncable>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun Synchronizer.changeListSync(model: String, changeListFetcher: suspend (currentVersion: Int) -> List<NetworkChangeList>, modelDeleter: suspend (ids: List<String>) -> Unit, modelUpdater: suspend (ids: List<String>) -> Unit): Boolean

Utility function for syncing a repository with the network. model Model that needs to be synced changeListFetcher Fetches the change list for the model modelDeleter Deletes models by consuming the ids of the models that have been deleted. modelUpdater Updates models by consuming the ids of the models that have changed.

suspend fun Synchronizer.changeListSync(models: List<String>, changeListFetcher: suspend (model: String, currentVersion: Int) -> List<NetworkChangeList>, modelDeleter: suspend (model: String, ids: List<String>) -> Unit, modelUpdater: suspend (model: String, ids: List<String>) -> Unit): Boolean

Utility function for syncing a repository with the network. models List of models that needs to be synced changeListFetcher Fetches the change list for the model modelDeleter Deletes models by consuming the ids of the models that have been deleted. modelUpdater Updates models by consuming the ids of the models that have changed.

Link copied to clipboard
open suspend override fun doWork(): ListenableWorker.Result
Link copied to clipboard
open suspend override fun getChangeListVersions(model: String): Int
Link copied to clipboard
open suspend override fun getForegroundInfo(): ForegroundInfo
Link copied to clipboard
override fun getForegroundInfoAsync(): ListenableFuture<ForegroundInfo>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@RequiresApi(value = 31)
fun getStopReason(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun onStopped()
Link copied to clipboard
suspend fun setForeground(foregroundInfo: ForegroundInfo)
Link copied to clipboard
fun setForegroundAsync(@NonNull foregroundInfo: ForegroundInfo): ListenableFuture<Void>
Link copied to clipboard
suspend fun setProgress(data: Data)
Link copied to clipboard
open fun setProgressAsync(@NonNull data: Data): ListenableFuture<Void>
Link copied to clipboard
Link copied to clipboard
override fun startWork(): ListenableFuture<ListenableWorker.Result>
Link copied to clipboard
Link copied to clipboard
open suspend fun Syncable.sync(): Boolean

Syntactic sugar to call Syncable.syncWith while omitting the synchronizer argument

Link copied to clipboard
open suspend override fun updateChangeListVersions(model: String, version: Int)