Search in sources :

Example 11 with ModuleItem

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);
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 12 with ModuleItem

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 13 with ModuleItem

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 14 with ModuleItem

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();
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull)

Example 15 with ModuleItem

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;
}
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

ModuleItem (com.instructure.canvasapi2.models.ModuleItem)16 Test (org.junit.Test)9 Course (com.instructure.canvasapi2.models.Course)8 Bundle (android.os.Bundle)7 ParentFragment (com.instructure.candroid.fragment.ParentFragment)7 NonNull (android.support.annotation.NonNull)3 View (android.view.View)2 ModuleObject (com.instructure.canvasapi2.models.ModuleObject)2 ArrayList (java.util.ArrayList)2 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 CardView (android.support.v7.widget.CardView)1 ModuleListRecyclerAdapter (com.instructure.candroid.adapter.ModuleListRecyclerAdapter)1 ModuleAdapterToFragmentCallback (com.instructure.candroid.interfaces.ModuleAdapterToFragmentCallback)1 ModuleProgressionUtility (com.instructure.candroid.util.ModuleProgressionUtility)1 AssignmentSet (com.instructure.canvasapi2.models.AssignmentSet)1 ModuleContentDetails (com.instructure.canvasapi2.models.ModuleContentDetails)1 ApiType (com.instructure.canvasapi2.utils.ApiType)1