Search in sources :

Example 1 with Data

use of androidx.work.Data in project ExoPlayer by google.

the class WorkManagerScheduler method schedule.

@Override
public boolean schedule(Requirements requirements, String servicePackage, String serviceAction) {
    Constraints constraints = buildConstraints(requirements);
    Data inputData = buildInputData(requirements, servicePackage, serviceAction);
    OneTimeWorkRequest workRequest = buildWorkRequest(constraints, inputData);
    workManager.enqueueUniqueWork(workName, ExistingWorkPolicy.REPLACE, workRequest);
    return true;
}
Also used : Constraints(androidx.work.Constraints) Data(androidx.work.Data) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 2 with Data

use of androidx.work.Data in project OneSignal-Android-SDK by OneSignal.

the class OSReceiveReceiptController method beginEnqueueingWork.

void beginEnqueueingWork(Context context, String osNotificationId) {
    if (!remoteParamController.isReceiveReceiptEnabled()) {
        OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "sendReceiveReceipt disabled");
        return;
    }
    int delay = OSUtils.getRandomDelay(minDelay, maxDelay);
    Data inputData = new Data.Builder().putString(OS_NOTIFICATION_ID, osNotificationId).build();
    Constraints constraints = buildConstraints();
    OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(ReceiveReceiptWorker.class).setConstraints(constraints).setInitialDelay(delay, TimeUnit.SECONDS).setInputData(inputData).build();
    OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "OSReceiveReceiptController enqueueing send receive receipt work with notificationId: " + osNotificationId + " and delay: " + delay + " seconds");
    WorkManager.getInstance(context).enqueueUniqueWork(osNotificationId + "_receive_receipt", ExistingWorkPolicy.KEEP, workRequest);
}
Also used : Constraints(androidx.work.Constraints) Data(androidx.work.Data) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 3 with Data

use of androidx.work.Data in project OneSignal-Android-SDK by OneSignal.

the class OSNotificationWorkManager method beginEnqueueingWork.

static void beginEnqueueingWork(Context context, String osNotificationId, int androidNotificationId, String jsonPayload, long timestamp, boolean isRestoring, boolean isHighPriority) {
    // TODO: Need to figure out how to implement the isHighPriority param
    Data inputData = new Data.Builder().putInt(ANDROID_NOTIF_ID_WORKER_DATA_PARAM, androidNotificationId).putString(JSON_PAYLOAD_WORKER_DATA_PARAM, jsonPayload).putLong(TIMESTAMP_WORKER_DATA_PARAM, timestamp).putBoolean(IS_RESTORING_WORKER_DATA_PARAM, isRestoring).build();
    OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(NotificationWorker.class).setInputData(inputData).build();
    OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "OSNotificationWorkManager enqueueing notification work with notificationId: " + osNotificationId + " and jsonPayload: " + jsonPayload);
    WorkManager.getInstance(context).enqueueUniqueWork(osNotificationId, ExistingWorkPolicy.KEEP, workRequest);
}
Also used : Data(androidx.work.Data) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Aggregations

Data (androidx.work.Data)3 OneTimeWorkRequest (androidx.work.OneTimeWorkRequest)3 Constraints (androidx.work.Constraints)2