use of com.tevinjeffrey.rutgersct.rutgersapi.exceptions.RutgersServerIOException in project Rutgers-Course-Tracker by tevjef.
the class SubjectFragment method showError.
@Override
public void showError(Throwable t) {
String message;
Resources resources = getContext().getResources();
if (t instanceof UnknownHostException) {
message = resources.getString(R.string.no_internet);
} else if (t instanceof JsonParseException || t instanceof RutgersServerIOException) {
message = resources.getString(R.string.server_down);
} else if (t instanceof RutgersDataIOException) {
notifySectionNotOpen();
getParentActivity().onBackPressed();
return;
} else if (t instanceof SocketTimeoutException) {
message = resources.getString(R.string.timed_out);
} else {
message = t.getMessage();
}
//error message finalized, now save it.
mViewState.errorMessage = message;
// Redirects the message that would usually be in the snackbar, to error layout.
if (!adapterHasItems()) {
showLayout(LayoutType.ERROR);
TextView textViewMessage = ButterKnife.findById(mErrorView, R.id.text);
textViewMessage.setText(message);
} else {
showSnackBar(message);
}
}
use of com.tevinjeffrey.rutgersct.rutgersapi.exceptions.RutgersServerIOException in project Rutgers-Course-Tracker by tevjef.
the class CourseFragment method showError.
@Override
public void showError(Throwable t) {
String message;
Resources resources = getContext().getResources();
if (t instanceof UnknownHostException) {
message = resources.getString(R.string.no_internet);
} else if (t instanceof JsonParseException || t instanceof RutgersServerIOException) {
message = resources.getString(R.string.server_down);
} else if (t instanceof SocketTimeoutException) {
message = resources.getString(R.string.timed_out);
} else {
message = t.getMessage();
}
//error message finalized, now save it.
mViewState.errorMessage = message;
// Redirects the message that would usually be in the snackbar, to error layout.
if (!adapterHasItems()) {
showLayout(LayoutType.ERROR);
TextView textViewMessage = ButterKnife.findById(mErrorView, R.id.text);
textViewMessage.setText(message);
} else {
showSnackBar(message);
}
}
use of com.tevinjeffrey.rutgersct.rutgersapi.exceptions.RutgersServerIOException in project Rutgers-Course-Tracker by tevjef.
the class TrackedSectionsFragment method showError.
@Override
public void showError(Throwable t) {
String message;
Resources resources = getContext().getResources();
if (t instanceof UnknownHostException) {
message = resources.getString(R.string.no_internet);
} else if (t instanceof JsonParseException || t instanceof RutgersServerIOException) {
message = resources.getString(R.string.server_down);
} else if (t instanceof SocketTimeoutException) {
message = resources.getString(R.string.timed_out);
} else {
message = t.getMessage();
}
// Save current error message ahead of config change.
mViewState.errorMessage = message;
// https://www.google.com/design/spec/patterns/errors.html#errors-app-errors
if (!adapterHasItems()) {
showLayout(LayoutType.ERROR);
TextView textViewMessage = ButterKnife.findById(mErrorView, R.id.text);
textViewMessage.setText(message);
} else {
showSnackBar(message);
}
}
Aggregations