use of com.instructure.canvasapi2.models.ModuleItem in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_subheader.
@Test
public void testGetFragment_subheader() {
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("SubHeader");
Course course = new Course();
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNull(parentFragment);
}
use of com.instructure.canvasapi2.models.ModuleItem in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_assignment.
@Test
public void testGetFragment_assignment() {
String url = "https://mobile.canvas.net/api/v1/courses/222/assignments/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Assignment");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putLong(Const.ASSIGNMENT_ID, 123456789);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(AssignmentFragment.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.ModuleItem in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_discussion.
@Test
public void testGetFragment_discussion() {
String url = "https://mobile.canvas.net/api/v1/courses/222/discussion_topics/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Discussion");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putLong(Const.TOPIC_ID, 123456789);
expectedBundle.putBoolean(Const.ANNOUNCEMENT, false);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(DiscussionDetailsFragment.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.ModuleItem in project instructure-android by instructure.
the class CourseModuleProgressionFragment method getQueryParamForBookmark.
@Override
@NonNull
public HashMap<String, String> getQueryParamForBookmark() {
ModuleItem item = getCurrentModuleItem(currentPos);
if (item != null) {
HashMap<String, String> map = new HashMap<>();
map.put(Param.MODULE_ITEM_ID, Long.toString(item.getId()));
return map;
}
return super.getQueryParamForBookmark();
}
use of com.instructure.canvasapi2.models.ModuleItem 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