Search in sources :

Example 11 with Submission

use of com.instructure.canvasapi.model.Submission 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

Submission (com.instructure.canvasapi.model.Submission)11 Drawable (android.graphics.drawable.Drawable)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 Attachment (com.instructure.canvasapi.model.Attachment)2 User (com.instructure.canvasapi.model.User)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 LongSparseArray (android.support.v4.util.LongSparseArray)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 ViewGroup (android.view.ViewGroup)1 Animation (android.view.animation.Animation)1 RotateAnimation (android.view.animation.RotateAnimation)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1 RadioGroup (android.widget.RadioGroup)1