@Override protected Boolean doInBackground(Void... notRelevant) { try { if (!isCancelled()) { setProgressAndNotify("Step 1 of 3 - Syncing Form Sections...", 0); formService.getPublishedFormSections(); } ArrayList<String> idsToDownload = getAllIdsForDownload(); setProgressAndNotify("Step 2 of 3 - Sending records to server...", 10); List<Child> childrenToSyncWithServer = childRepository.toBeSynced(); sendChildrenToServer(childrenToSyncWithServer); setProgressAndNotify("Step 3 of 3 - Bringing down records from server...", 20); saveIncomingChildren(idsToDownload); setProgressAndNotify("Sync complete.", 30); } catch (Exception e) { Log.e("SyncAllDataTask", "Error in sync", e); publishProgress("Error in syncing. Try again after some time."); return false; } return true; }
protected void getFormSections() throws IOException { if (!isCancelled()) { formService.getPublishedFormSections(); } }