Search in sources :

Example 1 with NetworkJob

use of com.battlelancer.seriesguide.jobs.NetworkJob in project SeriesGuide by UweTrottmann.

the class NetworkJobProcessor method doNetworkJob.

/**
 * @return true if the job can be removed, false if it should be retried later.
 */
private boolean doNetworkJob(long jobId, JobAction action, long createdAt, SgJobInfo jobInfo) {
    // upload to hexagon
    if (shouldSendToHexagon) {
        if (!AndroidUtils.isNetworkConnected(context)) {
            return false;
        }
        HexagonTools hexagonTools = SgApp.getServicesComponent(context).hexagonTools();
        NetworkJob hexagonJob = getHexagonJobForAction(hexagonTools, action, jobInfo);
        if (hexagonJob != null) {
            JobResult result = hexagonJob.execute(context);
            if (!result.successful) {
                showNotification(jobId, createdAt, result);
                return result.jobRemovable;
            }
        }
    }
    // upload to trakt
    if (shouldSendToTrakt) {
        if (!AndroidUtils.isNetworkConnected(context)) {
            return false;
        }
        NetworkJob traktJob = getTraktJobForAction(action, jobInfo, createdAt);
        if (traktJob != null) {
            JobResult result = traktJob.execute(context);
            // may need to show notification if successful (for not found error)
            showNotification(jobId, createdAt, result);
            if (!result.successful) {
                return result.jobRemovable;
            }
        }
    }
    return true;
}
Also used : HexagonTools(com.battlelancer.seriesguide.backend.HexagonTools) NetworkJob(com.battlelancer.seriesguide.jobs.NetworkJob)

Aggregations

HexagonTools (com.battlelancer.seriesguide.backend.HexagonTools)1 NetworkJob (com.battlelancer.seriesguide.jobs.NetworkJob)1