@Override public boolean onFired(ActionContext<? extends Application> context) { if (context.getApp().checkInternetAvailableAndRequired(context.getActivity())) { try { final SyncService service = syncServiceProxy.getService(); if (service != null) { doSync(context, service); } } catch (IllegalStateException ex) { cancelSync(context); } } return true; }
@Override protected void asyncPerform(ActionContext<? extends Application> context) throws Throwable { final Application app = context.getApp(); statistics = new StorageStatisticsCollector( app.getDbHelper().getReadOnlyDatabase(), app.getSettings().getDatabaseStorageProvider(), app.getSettings().getContentStorageProvider()) .getStorageStatistics(); }
protected void cancelSync(final ActionContext<? extends Application> context) { DialogFactory.buildYesNoDialog( context.getActivity(), R.string.sync_title, R.string.sync_cancel_confirmation, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final SyncService service = context.getApp().getSyncService().getService(); if (service != null) { service.cancelSync(); } } }) .show(); }
@Override protected void onSuccess(ActionContext<? extends Application> context) { if (statistics != null) { StorageStatisticsDialogHandler.start(context.getActivity(), statistics); } }