Search in sources :

Example 6 with Navigation

use of com.instructure.interactions.Navigation in project instructure-android by instructure.

the class NotificationListFragment method applyTheme.

@Override
public void applyTheme() {
    CanvasContext canvasContext = getCanvasContext();
    if (canvasContext instanceof Course || canvasContext instanceof Group) {
        PandaViewUtils.setupToolbarBackButton(mToolbar, this);
        ViewStyler.themeToolbar(getActivity(), mToolbar, canvasContext);
    } else {
        Navigation navigation = getNavigation();
        if (navigation != null)
            navigation.attachNavigationDrawer(this, mToolbar);
    // Styling done in attachNavigationDrawer
    }
}
Also used : ViewGroup(android.view.ViewGroup) Group(com.instructure.canvasapi2.models.Group) Navigation(com.instructure.interactions.Navigation) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) Course(com.instructure.canvasapi2.models.Course)

Example 7 with Navigation

use of com.instructure.interactions.Navigation in project instructure-android by instructure.

the class NotificationListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = getLayoutInflater().inflate(R.layout.fragment_list_notification, container, false);
    mToolbar = mRootView.findViewById(R.id.toolbar);
    mAdapterToFragmentCallback = new NotificationAdapterToFragmentCallback<StreamItem>() {

        @Override
        public void onRowClicked(StreamItem streamItem, int position, boolean isOpenDetail) {
            mRecyclerAdapter.setSelectedPosition(position);
            Navigation navigation = getNavigation();
            if (navigation != null) {
                onRowClick(streamItem, isOpenDetail);
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
            mEditOptions.setVisibility(View.GONE);
        }

        @Override
        public void onShowEditView(boolean isVisible) {
            mEditOptions.setVisibility(isVisible ? View.VISIBLE : View.GONE);
        }

        @Override
        public void onShowErrorCrouton(int message) {
            showToast(message);
        }
    };
    mRecyclerAdapter = new NotificationListRecyclerAdapter(getContext(), getCanvasContext(), onNotificationCountInvalidated, mAdapterToFragmentCallback);
    configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    PandaRecyclerView pandaRecyclerView = mRootView.findViewById(R.id.listView);
    pandaRecyclerView.setSelectionEnabled(false);
    configureViews(mRootView);
    return mRootView;
}
Also used : Navigation(com.instructure.interactions.Navigation) NotificationListRecyclerAdapter(com.instructure.candroid.adapter.NotificationListRecyclerAdapter) StreamItem(com.instructure.canvasapi2.models.StreamItem) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView)

Example 8 with Navigation

use of com.instructure.interactions.Navigation in project instructure-android by instructure.

the class NotificationListFragment method addFragmentForStreamItem.

public static DialogFragment addFragmentForStreamItem(StreamItem streamItem, FragmentActivity activity, boolean fromWidget) {
    ParentFragment fragment = null;
    if (streamItem == null || activity == null) {
        return null;
    }
    String unsupportedLabel = null;
    switch(streamItem.getType()) {
        case SUBMISSION:
            if (streamItem.getAssignment() == null && streamItem.getCanvasContext() instanceof Course) {
                fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(streamItem.getCanvasContext(), streamItem.getAssignmentId()));
            } else if (streamItem.getAssignment() != null && streamItem.getCanvasContext() instanceof Course) {
                // add an empty submission with the grade to the assignment so that we can see the score.
                Submission emptySubmission = new Submission();
                emptySubmission.setGrade(streamItem.getGrade());
                streamItem.getAssignment().setSubmission(emptySubmission);
                fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) streamItem.getCanvasContext(), streamItem.getAssignment()));
            }
            break;
        case ANNOUNCEMENT:
            if (streamItem.getCanvasContext() != null) {
                fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), true));
            }
            break;
        case CONVERSATION:
            Conversation conversation = streamItem.getConversation();
            if (conversation != null) {
                // Check to see if the conversation has been deleted.
                if (conversation.isDeleted()) {
                    Toast.makeText(activity, R.string.deleteConversation, Toast.LENGTH_SHORT).show();
                    return null;
                }
                Bundle extras = InboxConversationFragment.createBundle(conversation, 0, null);
                fragment = FragUtils.getFrag(InboxConversationFragment.class, extras);
            }
            break;
        case DISCUSSION_TOPIC:
            if (streamItem.getCanvasContext() != null) {
                fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), false));
            }
            break;
        case MESSAGE:
            if (streamItem.getAssignmentId() > 0) {
                if (streamItem.getCanvasContext() != null) {
                    fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(activity, streamItem.getCanvasContext(), streamItem.getAssignmentId(), streamItem));
                }
            } else {
                fragment = FragUtils.getFrag(UnknownItemFragment.class, UnknownItemFragment.createBundle(streamItem.getCanvasContext(), streamItem));
            }
            break;
        case COLLABORATION:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = activity.getString(R.string.collaborations);
                fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.COLLABORATIONS_ID, R.string.collaborations));
            }
            break;
        case CONFERENCE:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = activity.getString(R.string.conferences);
                fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.CONFERENCES_ID, R.string.conferences));
            }
            break;
        default:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = streamItem.getType().toString();
                fragment = FragUtils.getFrag(UnSupportedFeatureFragment.class, UnSupportedFeatureFragment.createBundle(streamItem.getCanvasContext(), unsupportedLabel, streamItem.getUrl()));
            }
            break;
    }
    if (unsupportedLabel != null) {
        if (activity instanceof Navigation) {
            ((Navigation) activity).addFragment(fragment);
        }
    } else {
        if (activity instanceof Navigation && fragment != null) {
            ((Navigation) activity).addFragment(fragment);
        }
        if (fromWidget) {
            if (streamItem.getUrl() != null) {
                RouterUtils.routeUrl(activity, streamItem.getUrl(), false);
            } else {
                RouterUtils.routeUrl(activity, streamItem.getHtmlUrl(), false);
            }
        }
    }
    return null;
}
Also used : Navigation(com.instructure.interactions.Navigation) Submission(com.instructure.canvasapi2.models.Submission) Bundle(android.os.Bundle) Conversation(com.instructure.canvasapi2.models.Conversation) Course(com.instructure.canvasapi2.models.Course)

Example 9 with Navigation

use of com.instructure.interactions.Navigation in project instructure-android by instructure.

the class QuizListFragment method rowClick.

private void rowClick(Quiz quiz, boolean closeSlidingPane) {
    Navigation navigation = getNavigation();
    if (navigation != null) {
        // to a webview. Also, we currently don't support one quiz question at a time quizzes.
        if (!isNativeQuiz(getCanvasContext(), quiz)) {
            // Log to GA, track if they're a teacher (because teachers currently always get the non native quiz)
            Bundle bundle = BasicQuizViewFragment.Companion.createBundle(getCanvasContext(), quiz.getUrl(), quiz);
            navigation.addFragment(FragUtils.getFrag(BasicQuizViewFragment.class, bundle));
        } else {
            Bundle bundle = QuizStartFragment.createBundle(getCanvasContext(), quiz);
            navigation.addFragment(FragUtils.getFrag(QuizStartFragment.class, bundle));
        }
    }
}
Also used : Navigation(com.instructure.interactions.Navigation) Bundle(android.os.Bundle)

Example 10 with Navigation

use of com.instructure.interactions.Navigation in project instructure-android by instructure.

the class ScheduleListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = getLayoutInflater().inflate(R.layout.fragment_list_syllabus, container, false);
    mToolbar = mRootView.findViewById(R.id.toolbar);
    mAdapterToFragmentCallback = new AdapterToFragmentCallback<ScheduleItem>() {

        @Override
        public void onRowClicked(ScheduleItem scheduleItem, int position, boolean isOpenDetail) {
            Navigation navigation = getNavigation();
            if (navigation != null) {
                ParentFragment fragment;
                if (scheduleItem.getAssignment() != null) {
                    fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) getCanvasContext(), scheduleItem.getAssignment()));
                } else if (scheduleItem.getItemType() == ScheduleItem.Type.TYPE_SYLLABUS) {
                    fragment = FragUtils.getFrag(SyllabusFragment.class, SyllabusFragment.Companion.createBundle((Course) getCanvasContext(), scheduleItem));
                } else {
                    fragment = FragUtils.getFrag(CalendarEventFragment.class, CalendarEventFragment.createBundle(getCanvasContext(), scheduleItem));
                }
                navigation.addFragment(fragment);
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }
    };
    mRecyclerAdapter = new SyllabusRecyclerAdapter(getContext(), getCanvasContext(), mAdapterToFragmentCallback);
    configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    return mRootView;
}
Also used : SyllabusRecyclerAdapter(com.instructure.candroid.adapter.SyllabusRecyclerAdapter) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Navigation(com.instructure.interactions.Navigation) Course(com.instructure.canvasapi2.models.Course)

Aggregations

Navigation (com.instructure.interactions.Navigation)17 Bundle (android.os.Bundle)10 Course (com.instructure.canvasapi2.models.Course)5 View (android.view.View)4 Submission (com.instructure.canvasapi2.models.Submission)3 PageView (com.instructure.canvasapi2.utils.pageview.PageView)3 CardView (android.support.v7.widget.CardView)2 AdapterView (android.widget.AdapterView)2 AdapterToFragmentCallback (com.instructure.candroid.interfaces.AdapterToFragmentCallback)2 Assignment (com.instructure.canvasapi2.models.Assignment)2 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Paint (android.graphics.Paint)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 AlertDialog (android.support.v7.app.AlertDialog)1 RecyclerView (android.support.v7.widget.RecyclerView)1 KeyEvent (android.view.KeyEvent)1 OnClickListener (android.view.View.OnClickListener)1 ViewGroup (android.view.ViewGroup)1