use of com.instructure.pandautils.utils.FileUploadEvent in project instructure-android by instructure.
the class AddSubmissionFragment method setUpCallback.
// /////////////////////////////////////////////////////////////////////////
// CallBack
// /////////////////////////////////////////////////////////////////////////
public void setUpCallback() {
canvasCallbackSubmission = new StatusCallback<Submission>() {
@Override
public void onResponse(@NonNull Response<Submission> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (!apiCheck()) {
return;
}
Submission result = response.body();
if (result.getBody() != null || result.getUrl() != null) {
Toast.makeText(getActivity(), R.string.successPostingSubmission, Toast.LENGTH_LONG).show();
// clear text fields because they are saved
textSubmission.setText("");
urlSubmission.setText("");
// Send broadcast so list is updated.
EventBus.getDefault().post(new FileUploadEvent(new FileUploadNotification(null, new ArrayList<Attachment>())));
Navigation navigation = getNavigation();
if (navigation != null)
navigation.popCurrentFragment();
} else {
Toast.makeText(getActivity(), R.string.errorPostingSubmission, Toast.LENGTH_LONG).show();
}
}
};
mLTIToolCallback = new StatusCallback<List<LTITool>>() {
@Override
public void onResponse(@NonNull Response<List<LTITool>> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
for (LTITool ltiTool : response.body()) {
final String url = ltiTool.getUrl();
if (url != null && url.contains("instructuremedia.com/lti/launch")) {
mArcUpload.setVisibility(View.VISIBLE);
mArcLTITool = ltiTool;
break;
}
}
// check to see if we should automatically show the file upload dialog
showFileUploadDialog();
}
@Override
public void onFail(@Nullable Call<List<LTITool>> call, @NonNull Throwable error, @Nullable Response response) {
// we don't want to show it if this failed due to there being no cache
if (response != null && response.code() != 504) {
showFileUploadDialog();
}
}
};
}
Aggregations