Search in sources :

Example 1 with EditAssignmentDialog

use of com.instructure.speedgrader.dialogs.EditAssignmentDialog in project instructure-android by instructure.

the class DocumentActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Submission currentSubmission = getCurrentSubmissionInViewpager();
    int id = item.getItemId();
    switch(id) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.edit_assignments:
            genericDialog = new EditAssignmentDialog();
            genericDialog.setArguments(EditAssignmentDialog.createBundle(mAssignment, (Course) mCanvasContext));
            genericDialog.show(getSupportFragmentManager(), EditAssignmentDialog.TAG);
            return true;
        case R.id.download:
            if (currentAttachment != null) {
                downloadFile(currentAttachment.getUrl(), currentAttachment.getFilename());
            } else if (currentSubmission.getSubmissionType() != null && currentSubmission.getSubmissionType().equals(mediaUpload)) {
                downloadFile(currentSubmission.getMediaComment().getUrl(), currentSubmission.getMediaComment().getFileName());
            } else {
                Toast.makeText(DocumentActivity.this, getString(R.string.nothingToDownload), Toast.LENGTH_SHORT).show();
            }
            return true;
        case R.id.open_browser:
            if (currentAttachment != null) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(currentAttachment.getUrl())));
            } else {
                Toast.makeText(DocumentActivity.this, getString(R.string.nothingToShowInBrowser), Toast.LENGTH_SHORT).show();
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Submission(com.instructure.canvasapi.model.Submission) EditAssignmentDialog(com.instructure.speedgrader.dialogs.EditAssignmentDialog) Intent(android.content.Intent) Course(com.instructure.canvasapi.model.Course)

Aggregations

Intent (android.content.Intent)1 Course (com.instructure.canvasapi.model.Course)1 Submission (com.instructure.canvasapi.model.Submission)1 EditAssignmentDialog (com.instructure.speedgrader.dialogs.EditAssignmentDialog)1