Search in sources :

Example 16 with Navigation

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

the class ModuleListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = getLayoutInflater().inflate(R.layout.fragment_module_list, container, false);
    mToolbar = rootView.findViewById(R.id.toolbar);
    CardView cardView = rootView.findViewById(R.id.cardView);
    if (cardView != null) {
        cardView.setCardBackgroundColor(Color.WHITE);
    }
    mRecyclerAdapter = new ModuleListRecyclerAdapter(mCourse, getDefaultSelectedId(), getContext(), getCanvasContext(), new ModuleAdapterToFragmentCallback() {

        @Override
        public void onRowClicked(ModuleObject moduleObject, ModuleItem moduleItem, int position, boolean isOpenDetail) {
            if (moduleItem.getType() != null && moduleItem.getType().equals(ModuleObject.STATE.unlock_requirements.toString())) {
                return;
            }
            // don't do anything with headers if the user selects it
            if (moduleItem.getType() != null && (moduleItem.getType().equals(ModuleItem.TYPE.SubHeader.toString()))) {
                return;
            }
            boolean isLocked = ModuleUtility.isGroupLocked(moduleObject);
            if (isLocked) {
                return;
            }
            // Remove all the subheaders and stuff.
            ArrayList<ModuleObject> groups = mRecyclerAdapter.getGroups();
            ArrayList<ArrayList<ModuleItem>> moduleItemsArray = new ArrayList<>();
            for (int i = 0; i < groups.size(); i++) {
                ArrayList<ModuleItem> moduleItems = mRecyclerAdapter.getItems(groups.get(i));
                moduleItemsArray.add(moduleItems);
            }
            ModuleProgressionUtility.ModuleHelper moduleHelper = ModuleProgressionUtility.prepareModulesForCourseProgression(getContext(), moduleItem.getId(), groups, moduleItemsArray);
            Navigation navigation = getNavigation();
            if (navigation != null) {
                Bundle bundle = CourseModuleProgressionFragment.createBundle(groups, moduleHelper.strippedModuleItems, mCourse, moduleHelper.newGroupPosition, moduleHelper.newChildPosition);
                navigation.addFragment(FragUtils.getFrag(CourseModuleProgressionFragment.class, bundle));
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }
    });
    configureRecyclerView(rootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    return rootView;
}
Also used : ModuleObject(com.instructure.canvasapi2.models.ModuleObject) Navigation(com.instructure.interactions.Navigation) Bundle(android.os.Bundle) CardView(android.support.v7.widget.CardView) ArrayList(java.util.ArrayList) View(android.view.View) CardView(android.support.v7.widget.CardView) PageView(com.instructure.canvasapi2.utils.pageview.PageView) ModuleListRecyclerAdapter(com.instructure.candroid.adapter.ModuleListRecyclerAdapter) ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ModuleProgressionUtility(com.instructure.candroid.util.ModuleProgressionUtility) ModuleAdapterToFragmentCallback(com.instructure.candroid.interfaces.ModuleAdapterToFragmentCallback)

Example 17 with Navigation

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

the class PageListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (mIsShowFrontPage) {
        Bundle bundle = PageDetailsFragment.Companion.createBundle(Page.FRONT_PAGE_NAME, getCanvasContext());
        Navigation navigation = getNavigation();
        if (navigation != null) {
            ParentFragment fragment = createFragment(PageDetailsFragment.class, bundle);
            navigation.addFragment(fragment, true);
        }
    }
}
Also used : Navigation(com.instructure.interactions.Navigation) Bundle(android.os.Bundle)

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