Search in sources :

Example 1 with ModuleAdapterToFragmentCallback

use of com.instructure.candroid.interfaces.ModuleAdapterToFragmentCallback 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)

Aggregations

Bundle (android.os.Bundle)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 ModuleListRecyclerAdapter (com.instructure.candroid.adapter.ModuleListRecyclerAdapter)1 ModuleAdapterToFragmentCallback (com.instructure.candroid.interfaces.ModuleAdapterToFragmentCallback)1 ModuleProgressionUtility (com.instructure.candroid.util.ModuleProgressionUtility)1 ModuleItem (com.instructure.canvasapi2.models.ModuleItem)1 ModuleObject (com.instructure.canvasapi2.models.ModuleObject)1 PageView (com.instructure.canvasapi2.utils.pageview.PageView)1 Navigation (com.instructure.interactions.Navigation)1 ArrayList (java.util.ArrayList)1