use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class InternalWebViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getToolbar() != null) {
ViewStyler.themeToolbar(this, getToolbar(), Color.WHITE, Color.BLACK, false);
}
if (savedInstanceState == null) {
Bundle bundle = getIntent().getBundleExtra(Const.EXTRAS);
if (bundle.containsKey(Const.ACTION_BAR_TITLE)) {
getToolbar().setTitle(bundle.getString(Const.ACTION_BAR_TITLE));
}
if (bundle.containsKey(Const.CANVAS_CONTEXT)) {
CanvasContext canvasContext = bundle.getParcelable(Const.CANVAS_CONTEXT);
if (canvasContext != null) {
// want the internalWebViewFragment to hide its toolbar
if (canvasContext.getId() == 0) {
bundle.putBoolean(HIDE_TOOLBAR, true);
} else {
// todo fix actionbar setting with viewstyler
final int color = ColorKeeper.getOrGenerateColor(canvasContext);
setActionBarStatusBarColors(color, color);
getSupportActionBar().setTitle(canvasContext.getName());
}
}
}
InternalWebviewFragment fragment = FragUtils.getFrag(InternalWebviewFragment.class, bundle);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.container, fragment, InternalWebviewFragment.class.getName());
ft.commitAllowingStateLoss();
}
}
use of com.instructure.canvasapi2.models.CanvasContext 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.models.CanvasContext in project instructure-android by instructure.
the class QuizManager method getFirstPageQuizSubmissions.
public static void getFirstPageQuizSubmissions(CanvasContext canvasContext, long quizId, final boolean forceNetwork, final StatusCallback<QuizSubmissionResponse> callback) {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
QuizAPI.getFirstPageQuizSubmissions(canvasContext, quizId, adapter, params, callback);
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class QuizManager method startQuiz.
public static void startQuiz(CanvasContext canvasContext, long quizId, boolean forceNetwork, final StatusCallback<QuizSubmissionResponse> callback) {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
QuizAPI.startQuiz(canvasContext, quizId, adapter, params, callback);
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class QuizManager method getAllQuizSubmissions.
public static void getAllQuizSubmissions(final CanvasContext canvasContext, final long quizId, final boolean forceNetwork, final StatusCallback<List<QuizSubmission>> callback) {
if (isTesting() || mTesting) {
QuizManager_Test.getAllQuizSubmissions(callback);
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
final ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission> paginatedCallback = new ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission>(callback) {
@Override
public void getNextPage(@NotNull StatusCallback<QuizSubmissionResponse> callback, @NotNull String nextUrl, boolean isCached) {
QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, callback, params);
}
@NotNull
@Override
public List<QuizSubmission> extractItems(QuizSubmissionResponse response) {
return response.getQuizSubmissions();
}
};
adapter.setStatusCallback(paginatedCallback);
QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, paginatedCallback, params);
}
}
Aggregations