use of org.fossasia.openevent.common.events.DataDownloadEvent in project open-event-android by fossasia.
the class MainActivity method downloadFailed.
private void downloadFailed(final DownloadEvent event) {
Snackbar.make(mainFrame, getString(R.string.download_failed), Snackbar.LENGTH_LONG).setAction(R.string.retry_download, view -> {
if (event == null)
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
else
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(event);
}).show();
SharedPreferencesUtil.putBoolean(ConstantStrings.IS_DOWNLOAD_DONE, false);
}
use of org.fossasia.openevent.common.events.DataDownloadEvent in project open-event-android by fossasia.
the class MainActivity method startDownloadFromNetwork.
private void startDownloadFromNetwork() {
fromServer = true;
boolean preference = SharedPreferencesUtil.getBoolean(getResources().getString(R.string.download_mode_key), true);
if (preference) {
disposable.add(NetworkUtils.haveNetworkConnectionObservable(MainActivity.this).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(isConnected -> {
if (isConnected) {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
} else {
final Snackbar snackbar = Snackbar.make(mainFrame, R.string.internet_preference_warning, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.yes, view -> downloadFromAssets());
snackbar.show();
}
}));
} else {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
}
}
Aggregations