Skip to content

Commit

Permalink
Rename periodic workers to make them easier to identify
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Jul 18, 2022
1 parent 5db221e commit 083cc53
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import com.owncloud.android.workers.AvailableOfflinePeriodicWorker
import com.owncloud.android.workers.AvailableOfflinePeriodicWorker.Companion.AVAILABLE_OFFLINE_PERIODIC_WORKER
import com.owncloud.android.workers.CameraUploadsWorker
import com.owncloud.android.workers.OldLogsCollectorWorker
import com.owncloud.android.workers.CameraUploadsPeriodicWorker
import com.owncloud.android.workers.OldLogsCollectorPeriodicWorker

class WorkManagerProvider(
val context: Context
) {
fun enqueueCameraUploadsWorker() {
val cameraUploadsWorker = PeriodicWorkRequestBuilder<CameraUploadsWorker>(
repeatInterval = CameraUploadsWorker.repeatInterval,
repeatIntervalTimeUnit = CameraUploadsWorker.repeatIntervalTimeUnit
).addTag(CameraUploadsWorker.CAMERA_UPLOADS_WORKER)
val cameraUploadsPeriodicWorker = PeriodicWorkRequestBuilder<CameraUploadsPeriodicWorker>(
repeatInterval = CameraUploadsPeriodicWorker.repeatInterval,
repeatIntervalTimeUnit = CameraUploadsPeriodicWorker.repeatIntervalTimeUnit
).addTag(CameraUploadsPeriodicWorker.CAMERA_UPLOADS_WORKER)
.build()

WorkManager.getInstance(context)
.enqueueUniquePeriodicWork(CameraUploadsWorker.CAMERA_UPLOADS_WORKER, ExistingPeriodicWorkPolicy.KEEP, cameraUploadsWorker)
.enqueueUniquePeriodicWork(CameraUploadsPeriodicWorker.CAMERA_UPLOADS_WORKER, ExistingPeriodicWorkPolicy.KEEP, cameraUploadsPeriodicWorker)
}

fun enqueueOldLogsCollectorWorker() {
val constraintsRequired = Constraints.Builder().setRequiredNetworkType(NetworkType.NOT_REQUIRED).build()

val oldLogsCollectorWorker = PeriodicWorkRequestBuilder<OldLogsCollectorWorker>(
repeatInterval = OldLogsCollectorWorker.repeatInterval,
repeatIntervalTimeUnit = OldLogsCollectorWorker.repeatIntervalTimeUnit
val oldLogsCollectorPeriodicWorker = PeriodicWorkRequestBuilder<OldLogsCollectorPeriodicWorker>(
repeatInterval = OldLogsCollectorPeriodicWorker.repeatInterval,
repeatIntervalTimeUnit = OldLogsCollectorPeriodicWorker.repeatIntervalTimeUnit
)
.addTag(OldLogsCollectorWorker.OLD_LOGS_COLLECTOR_WORKER)
.addTag(OldLogsCollectorPeriodicWorker.OLD_LOGS_COLLECTOR_WORKER)
.setConstraints(constraintsRequired)
.build()

WorkManager.getInstance(context)
.enqueueUniquePeriodicWork(OldLogsCollectorWorker.OLD_LOGS_COLLECTOR_WORKER, ExistingPeriodicWorkPolicy.REPLACE, oldLogsCollectorWorker)
.enqueueUniquePeriodicWork(OldLogsCollectorPeriodicWorker.OLD_LOGS_COLLECTOR_WORKER, ExistingPeriodicWorkPolicy.REPLACE, oldLogsCollectorPeriodicWorker)
}

fun enqueueAvailableOfflinePeriodicWorker() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import java.io.File
import java.util.Date
import java.util.concurrent.TimeUnit

class CameraUploadsWorker(
class CameraUploadsPeriodicWorker(
val appContext: Context,
workerParameters: WorkerParameters
) : CoroutineWorker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.io.IOException
import java.util.Calendar
import java.util.concurrent.TimeUnit

class OldLogsCollectorWorker(
class OldLogsCollectorPeriodicWorker(
val appContext: Context,
workerParameters: WorkerParameters
) : CoroutineWorker(
Expand Down

0 comments on commit 083cc53

Please sign in to comment.