This is a fork of the Android MVP Clean Architecture template project https://github.com/android10/Android-CleanArchitecture
There is no infrastructure to automatically retry unsuccessful Use Cases. If a Use Case fails for some reason (typically due to a network error but not neccesarily) the UI shows an error message and the user can manually retry the Use Case.
This template project adds a Job Scheduler to the original one to allow to automatically retry and customize the conditions of unsucessful Use Cases.
This template project uses Android-priority-jobqueue as the Job Scheduler https://github.com/yigit/android-priority-jobqueue Other alternatives are GCM Network Manager (requires Google Play Services) or Android-job by Evernote.
-
Wrap your Use Cases into UseCaseWrapper(UseCase, Params, ObserverCallbacks). Your Use Cases shouldn't be modified or affected at all.
-
Wrap and extend each UseCaseWrapper into Jobs (concrete implementation of the JobScheduler). Indicate the requirements of this Job. Example: requireNetwork, persist, unique, retry policy, etc.
-
Instead of executing the Use Cases in the Presenters inject the Job Scheduler in the presenters and add the UseCaseWrapperJob to the Job Scheduler. The Job Scheduler will take care of them according to their requirements.
jobScheduler.execute(useCaseWrapperJob)