Search in sources :

Example 61 with CanvasContext

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();
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) InternalWebviewFragment(com.instructure.candroid.fragment.InternalWebviewFragment) Bundle(android.os.Bundle) CanvasContext(com.instructure.canvasapi2.models.CanvasContext)

Example 62 with CanvasContext

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();
            }
        }
    });
}
Also used : Response(retrofit2.Response) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) FileFolder(com.instructure.canvasapi2.models.FileFolder) ApiType(com.instructure.canvasapi2.utils.ApiType) CanvasContext(com.instructure.canvasapi2.models.CanvasContext)

Example 63 with CanvasContext

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);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 64 with CanvasContext

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);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 65 with CanvasContext

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);
    }
}
Also used : QuizSubmission(com.instructure.canvasapi2.models.QuizSubmission) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) StatusCallback(com.instructure.canvasapi2.StatusCallback) NotNull(org.jetbrains.annotations.NotNull) ExhaustiveCallback(com.instructure.canvasapi2.utils.ExhaustiveCallback) QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)60 RestParams (com.instructure.canvasapi2.builders.RestParams)55 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)19 StatusCallback (com.instructure.canvasapi2.StatusCallback)8 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)7 List (java.util.List)7 ApiType (com.instructure.canvasapi2.utils.ApiType)6 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)6 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)5 FileFolder (com.instructure.canvasapi2.models.FileFolder)5 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)5 NonNull (android.support.annotation.NonNull)4 View (android.view.View)4 TextView (android.widget.TextView)4 UpdateFileFolder (com.instructure.canvasapi2.models.UpdateFileFolder)4 Bundle (android.os.Bundle)3 ImageView (android.widget.ImageView)3 BindView (butterknife.BindView)3 Course (com.instructure.canvasapi2.models.Course)3