use of org.fossasia.openevent.common.events.ShowNetworkDialogEvent in project open-event-android by fossasia.
the class MainActivity method errorHandlerEvent.
@Subscribe
public void errorHandlerEvent(RetrofitError error) {
String errorType;
String errorDesc;
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netinfo = connMgr != null ? connMgr.getActiveNetworkInfo() : null;
if (!(netinfo != null && netinfo.isConnected())) {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new ShowNetworkDialogEvent());
} else {
if (error.getThrowable() instanceof IOException) {
errorType = "Timeout";
errorDesc = String.valueOf(error.getThrowable().getCause());
} else if (error.getThrowable() instanceof IllegalStateException) {
errorType = "ConversionError";
errorDesc = String.valueOf(error.getThrowable().getCause());
} else {
errorType = "Other Error";
errorDesc = String.valueOf(error.getThrowable().getLocalizedMessage());
}
Timber.tag(errorType).e(errorDesc);
showErrorSnackbar(errorType, errorDesc);
}
}
use of org.fossasia.openevent.common.events.ShowNetworkDialogEvent in project open-event-android by fossasia.
the class MainActivity method showNetworkDialog.
@Subscribe
public void showNetworkDialog(ShowNetworkDialogEvent event) {
completeHandler.hide();
if (dialogNetworkNotification == null) {
dialogNetworkNotification = DialogFactory.createCancellableSimpleActionDialog(this, R.string.net_unavailable, R.string.turn_on, R.string.ok, R.string.cancel, (dialogInterface, button) -> {
switch(button) {
case DialogInterface.BUTTON_POSITIVE:
Intent setNetworkIntent = new Intent(Settings.ACTION_SETTINGS);
startActivity(setNetworkIntent);
break;
case DialogInterface.BUTTON_NEGATIVE:
dialogNetworkNotification.dismiss();
return;
default:
}
});
}
dialogNetworkNotification.show();
}
Aggregations