use of com.instructure.canvasapi2.utils.ApiType in project instructure-android by instructure.
the class FileFolderManager method getAllFilesRoot.
public static void getAllFilesRoot(CanvasContext canvasContext, final boolean forceNetwork, final StatusCallback<List<FileFolder>> callback) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
FileFolderAPI.getRootFolderForContext(adapter, canvasContext, new StatusCallback<FileFolder>() {
@Override
public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
getAllFiles(response.body().getId(), forceNetwork, callback);
}
}, params);
}
}
use of com.instructure.canvasapi2.utils.ApiType in project instructure-android by instructure.
the class BaseRouterActivity method handleSpecificFile.
private void handleSpecificFile(long courseId, String fileID) {
final CanvasContext canvasContext = CanvasContext.getGenericContext(CanvasContext.Type.COURSE, courseId, "");
Logger.d("handleSpecificFile()");
FileFolderManager.getFileFolderFromURLAirwolf(ApiPrefs.getAirwolfDomain(), "files/" + fileID, new StatusCallback<FileFolder>() {
@Override
public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (type == ApiType.API) {
FileFolder fileFolder = response.body();
if (fileFolder == null || response.code() == 404) {
Toast.makeText(BaseRouterActivity.this, R.string.fileNoLongerExists, Toast.LENGTH_LONG).show();
} else {
if (fileFolder.isLocked() || fileFolder.isLockedForUser()) {
Toast.makeText(BaseRouterActivity.this, String.format(getString(R.string.fileLocked), (fileFolder.getDisplayName() == null) ? getString(R.string.file) : fileFolder.getDisplayName()), Toast.LENGTH_LONG).show();
} else {
downloadMedia(BaseRouterActivity.this, fileFolder.getContentType(), fileFolder.getUrl(), fileFolder.getDisplayName());
}
}
}
}
@Override
public void onFail(@Nullable Call<FileFolder> call, @NonNull Throwable error, @Nullable Response response) {
if (response != null && response.code() == 404) {
Toast.makeText(BaseRouterActivity.this, R.string.fileNoLongerExists, Toast.LENGTH_LONG).show();
}
}
});
}
use of com.instructure.canvasapi2.utils.ApiType in project instructure-android by instructure.
the class SettingsActivity method removeStudent.
public void removeStudent(final Student student) {
AnalyticUtils.trackButtonPressed(AnalyticUtils.REMOVE_STUDENT);
setResult(RESULT_OK);
final ProgressDialog dialog = ProgressDialog.show(SettingsActivity.this, getString(R.string.removingStudent), "", true, false);
dialog.show();
// this api call removes student data from the db (like alerts info).
UserManager.removeStudentAirwolf(ApiPrefs.getAirwolfDomain(), student.getParentId(), student.getStudentId(), new StatusCallback<ResponseBody>() {
@Override
public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
dialog.dismiss();
Toast.makeText(SettingsActivity.this, getString(R.string.studentRemoved), Toast.LENGTH_SHORT).show();
int adapterSizeBeforeRemove = getAdapter().size();
boolean removed = getAdapter().removeItem(student);
if (removed && adapterSizeBeforeRemove == 1) {
// Catches case for removing last student
finish();
}
}
});
}
Aggregations