Search in sources :

Example 1 with FormUpdateAndInstanceSubmitScheduler

use of org.odk.collect.android.backgroundwork.FormUpdateAndInstanceSubmitScheduler in project collect by opendatakit.

the class InstanceUploaderListActivity method updateAutoSendStatus.

/**
 * Updates whether an auto-send job is ongoing.
 */
private void updateAutoSendStatus() {
    // This shouldn't use WorkManager directly but it's likely this code will be removed when
    // we eventually move sending forms to a Foreground Service (rather than a blocking AsyncTask)
    String tag = ((FormUpdateAndInstanceSubmitScheduler) instanceSubmitScheduler).getAutoSendTag(currentProjectProvider.getCurrentProject().getUuid());
    LiveData<List<WorkInfo>> statuses = WorkManager.getInstance().getWorkInfosForUniqueWorkLiveData(tag);
    statuses.observe(this, workStatuses -> {
        if (workStatuses != null) {
            for (WorkInfo status : workStatuses) {
                if (status.getState().equals(WorkInfo.State.RUNNING)) {
                    autoSendOngoing = true;
                    return;
                }
            }
            autoSendOngoing = false;
        }
    });
}
Also used : WorkInfo(androidx.work.WorkInfo) List(java.util.List) FormUpdateAndInstanceSubmitScheduler(org.odk.collect.android.backgroundwork.FormUpdateAndInstanceSubmitScheduler)

Aggregations

WorkInfo (androidx.work.WorkInfo)1 List (java.util.List)1 FormUpdateAndInstanceSubmitScheduler (org.odk.collect.android.backgroundwork.FormUpdateAndInstanceSubmitScheduler)1