use of com.instructure.canvasapi2.StatusCallback in project instructure-android by instructure.
the class PollsManager method getNextPagePollSessions.
public static void getNextPagePollSessions(String nextUrl, StatusCallback<PollSessionResponse> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO:
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
PollsSessionAPI.getNextPagePollSessions(nextUrl, adapter, params, callback);
}
}
use of com.instructure.canvasapi2.StatusCallback in project instructure-android by instructure.
the class PollsManager method updatePollSession.
public static void updatePollSession(long pollId, long pollSessionId, long courseId, long sectionId, boolean hasPublicResults, StatusCallback<PollSessionResponse> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO:
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
PollsSessionAPI.updatePollSession(pollId, pollSessionId, courseId, sectionId, hasPublicResults, adapter, params, callback);
}
}
use of com.instructure.canvasapi2.StatusCallback in project instructure-android by instructure.
the class PollsManager method getPollSubmission.
public static void getPollSubmission(long pollId, long pollSessionId, long pollSubmissionId, StatusCallback<PollSubmissionResponse> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO:
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
PollSubmissionAPI.getPollSubmission(pollId, pollSessionId, pollSubmissionId, adapter, params, callback);
}
}
use of com.instructure.canvasapi2.StatusCallback in project instructure-android by instructure.
the class CourseModuleProgressionFragment method setButtonListeners.
private void setButtonListeners() {
prev.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setupPrevModuleName(currentPos);
setupPreviousModule(getModuleItemGroup(currentPos));
if (currentPos >= 1) {
viewPager.setCurrentItem(--currentPos);
}
updateBottomNavBarButtons();
}
});
next.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setupNextModuleName(currentPos);
setupNextModule(getModuleItemGroup(currentPos));
if (currentPos < (NUM_ITEMS - 1)) {
viewPager.setCurrentItem(++currentPos);
}
updateBottomNavBarButtons();
}
});
markDoneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (getModelObject() != null && getModelObject().getCompletionRequirement() != null) {
if (getModelObject().getCompletionRequirement().isCompleted()) {
ModuleManager.markAsNotDone(getCanvasContext(), getModelObject().getModuleId(), getModelObject().getId(), new StatusCallback<ResponseBody>() {
@Override
public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
markDoneCheckBox.setChecked(false);
getModelObject().getCompletionRequirement().setCompleted(false);
notifyOfItemChanged(getModelObject());
}
});
} else {
ModuleManager.markAsDone(getCanvasContext(), getModelObject().getModuleId(), getModelObject().getId(), new StatusCallback<ResponseBody>() {
@Override
public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
markDoneCheckBox.setChecked(true);
getModelObject().getCompletionRequirement().setCompleted(true);
notifyOfItemChanged(getModelObject());
}
});
}
}
}
});
}
use of com.instructure.canvasapi2.StatusCallback in project instructure-android by instructure.
the class FileDetailsFragment method setUpCallback.
public void setUpCallback() {
fileFolderCanvasCallback = new StatusCallback<FileFolder>() {
@Override
public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (!apiCheck()) {
return;
}
// set up everything else now, we should have a file
file = response.body();
if (file != null) {
if (file.getLockInfo() != null) {
// file is locked
icon.setImageResource(R.drawable.vd_lock);
openButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
fileTypeTextView.setVisibility(View.INVISIBLE);
String lockedMessage = "";
if (file.getLockInfo().getLockedModuleName() != null) {
lockedMessage = "<p>" + String.format(getActivity().getString(R.string.lockedFileDesc), "<b>" + file.getLockInfo().getLockedModuleName() + "</b>") + "</p>";
}
if (file.getLockInfo().getModulePrerequisiteNames().size() > 0) {
// we only want to add this text if there are module completion requirements
lockedMessage += getActivity().getString(R.string.mustComplete) + "<br>";
// textViews can't display <ul> and <li> tags, so we need to use "• " instead
for (int i = 0; i < file.getLockInfo().getModulePrerequisiteNames().size(); i++) {
// "• "
lockedMessage += "• " + file.getLockInfo().getModulePrerequisiteNames().get(i);
}
lockedMessage += "<br><br>";
}
// check to see if there is an unlocked date
if (file.getLockInfo().getUnlockAt() != null && file.getLockInfo().getUnlockAt().after(new Date())) {
lockedMessage += DateHelper.createPrefixedDateTimeString(getContext(), getActivity().getString(R.string.unlockedAt) + "<br>• ", file.getLockInfo().getUnlockAt());
}
fileNameTextView.setText(StringUtilities.simplifyHTML(Html.fromHtml(lockedMessage)));
} else {
setupTextViews();
setupClickListeners();
// if the file has a thumbnail then show it. Make it a little bigger since the thumbnail size is pretty small
if (!TextUtils.isEmpty(file.getThumbnailUrl())) {
int dp = (int) ViewUtils.convertDipsToPixels(150, getActivity());
Picasso.with(getActivity()).load(file.getThumbnailUrl()).resize(dp, dp).centerInside().into(icon);
}
}
setPageViewReady();
}
toolbar.setTitle(title());
}
};
markReadCanvasCallback = new StatusCallback<ResponseBody>() {
@Override
public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
}
};
}
Aggregations