use of com.instructure.canvasapi2.models.MismatchedRegionResponse in project instructure-android by instructure.
the class BaseParentActivity method handleError.
public void handleError(int code, String error) {
if (code == 418) {
// Parse the message from the response body
Gson gson = new Gson();
JsonParser parser = new JsonParser();
JsonElement mJson = parser.parse(error);
RevokedTokenResponse revokedTokenResponse = gson.fromJson(mJson, RevokedTokenResponse.class);
showRevokedTokenDialog(revokedTokenResponse, this);
}
if (code == 403) {
// Parse the message from the response body
Gson gson = new Gson();
JsonParser parser = new JsonParser();
JsonElement mJson = parser.parse(error);
BlockedStudentResponse blockedStudentResponse = gson.fromJson(mJson, BlockedStudentResponse.class);
if (blockedStudentResponse.code.equals("studentBlocked")) {
Prefs prefs = new Prefs(this, getString(R.string.app_name_parent));
String parentId = prefs.load(Const.ID, "");
// We want to refresh cache so the main activity can load quickly with accurate information
UserManager.getStudentsForParentAirwolf(ApiPrefs.getAirwolfDomain(), parentId, new StatusCallback<List<Student>>() {
@Override
public void onResponse(@NonNull Response<List<Student>> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (response.body() != null && !response.body().isEmpty()) {
// They have students that they are observing, take them to that activity
startActivity(StudentViewActivity.createIntent(BaseParentActivity.this, response.body()));
overridePendingTransition(0, 0);
finish();
} else {
// Take the parent to the add user page.
FindSchoolActivity.Companion.createIntent(BaseParentActivity.this, true);
finish();
}
}
});
}
}
if (code == 451) {
// Parse the message from the response body
Gson gson = new Gson();
JsonParser parser = new JsonParser();
JsonElement mJson = parser.parse(error);
MismatchedRegionResponse mismatchedRegionResponse = gson.fromJson(mJson, MismatchedRegionResponse.class);
showMismatchedRegionDialog(mismatchedRegionResponse.getStudentRegion(), this);
}
}
Aggregations