use of com.instructure.candroid.adapter.ModuleListRecyclerAdapter 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;
}
Aggregations