Search in sources :

Example 1 with Section

use of com.instructure.canvasapi.model.Section in project instructure-android by instructure.

the class SectionUnitTest method sectionsTest.

@Test
public void sectionsTest() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    Section[] sections = gson.fromJson(sectionJSON, Section[].class);
    assertNotNull(sections);
    Section section = sections[0];
    assertNotNull(section);
    assertTrue(section.getCourse_id() == 1098050);
    assertTrue(section.getId() == 1243410);
    assertNull(section.getEnd_at());
}
Also used : Gson(com.google.gson.Gson) Section(com.instructure.canvasapi.model.Section) Test(org.junit.Test)

Example 2 with Section

use of com.instructure.canvasapi.model.Section in project instructure-android by instructure.

the class AssignmentListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    if (savedInstanceState != null) {
        loadSavedInstanceState(savedInstanceState);
    }
    mAdapterToFragmentCallback = new AssignmentAdapterToFragmentCallback() {

        @Override
        public void onRowClicked(Assignment assignment) {
            if (mSectionsSpinner.getSelectedItem() != null) {
                startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, ((Section) mSectionsSpinner.getSelectedItem()).getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
            } else {
                startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }

        @Override
        public Section getCurrentSection() {
            if (mSectionsSpinner == null || mSectionsSpinner.getSelectedItem() == null) {
                return getAllSectionsItem();
            }
            return (Section) mSectionsSpinner.getSelectedItem();
        }

        @Override
        public void onSectionsLoaded(List<Section> sections) {
            if (!isAdded()) {
                return;
            }
            mSections = sections;
            if (mSectionsSpinner != null) {
                createSectionsSpinner();
            }
        }
    };
    if (mRecyclerAdapter == null) {
        mRecyclerAdapter = new AssignmentGroupListRecyclerAdapter(getContext(), getCanvasContext(), mAdapterToFragmentCallback);
    }
    if (getActivity() instanceof HomeActivity) {
        ((HomeActivity) getActivity()).hideDrawer();
    }
    handleActionBarColor();
    setTitle(getCanvasContext().getName());
    configureRecyclerViewAsGrid(mRootView, mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    if (isRouting) {
        isRouting = false;
        startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), mRoutedAssignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
        getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
    return mRootView;
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) HomeActivity(com.instructure.speedgrader.activities.HomeActivity) AssignmentGroupListRecyclerAdapter(com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter) AssignmentAdapterToFragmentCallback(com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback) Section(com.instructure.canvasapi.model.Section)

Example 3 with Section

use of com.instructure.canvasapi.model.Section in project instructure-android by instructure.

the class DocumentActivity method getAllSectionsItem.

private Section getAllSectionsItem() {
    Section tempSection = new Section();
    tempSection.setId(Integer.MIN_VALUE);
    tempSection.setName(getResources().getString(R.string.allSections));
    return tempSection;
}
Also used : Section(com.instructure.canvasapi.model.Section)

Example 4 with Section

use of com.instructure.canvasapi.model.Section in project instructure-android by instructure.

the class SectionUnitTest method sectionsWithStudentsTest.

@Test
public void sectionsWithStudentsTest() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    Section[] sections = gson.fromJson(sectionsWithStudentsJSON, Section[].class);
    assertNotNull(sections);
    Section section = sections[0];
    assertNotNull(section);
    List<User> sectionStudents = section.getStudents();
    assertNotNull(sectionStudents);
    User user = sectionStudents.get(0);
    assertNotNull(user);
    assertTrue(user.getId() == 3558540);
    assertNotNull(user.getName());
    assertNotNull(user.getShortName());
}
Also used : User(com.instructure.canvasapi.model.User) Gson(com.google.gson.Gson) Section(com.instructure.canvasapi.model.Section) Test(org.junit.Test)

Example 5 with Section

use of com.instructure.canvasapi.model.Section in project instructure-android by instructure.

the class CourseListFragment method onRowClick.

@Override
public boolean onRowClick(CanvasContext item) {
    Bundle bundle = new Bundle();
    Section section = (Section) item;
    section.getCourse_id();
    CanvasContext course = courseGroupMap.get(section.getCourse_id());
    bundle.putParcelable(Const.SECTION, item);
    bundle.putParcelable(Const.COURSE, course);
    bundle.putParcelableArrayList(Const.SECTION_PEOPLE, (ArrayList<User>) ((Section) item).getStudents());
    if (nextFragment == Const.HOT_SEAT) {
        StudentChooserFragment studentChooserFragment = new StudentChooserFragment();
        studentChooserFragment.setArguments(bundle);
        getParentActivity().swapFragment(studentChooserFragment, StudentChooserFragment.TAG);
    } else if (nextFragment == Const.GUESS_WHO) {
        GuessWhoFragment guessWhoFragment = new GuessWhoFragment();
        guessWhoFragment.setArguments(bundle);
        getParentActivity().swapFragment(guessWhoFragment, GuessWhoFragment.TAG);
    } else if (nextFragment == Const.STUDENT_NOTES) {
        StudentNotesFragment studentNotesFragment = new StudentNotesFragment();
        studentNotesFragment.setArguments(bundle);
        getParentActivity().swapFragment(studentNotesFragment, StudentNotesFragment.TAG);
    }
    return true;
}
Also used : User(com.instructure.canvasapi.model.User) Bundle(android.os.Bundle) CanvasContext(com.instructure.canvasapi.model.CanvasContext) Section(com.instructure.canvasapi.model.Section)

Aggregations

Section (com.instructure.canvasapi.model.Section)8 Gson (com.google.gson.Gson)2 User (com.instructure.canvasapi.model.User)2 Test (org.junit.Test)2 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 View (android.view.View)1 Assignment (com.instructure.canvasapi.model.Assignment)1 CanvasContext (com.instructure.canvasapi.model.CanvasContext)1 Course (com.instructure.canvasapi.model.Course)1 NeedsGradingCount (com.instructure.canvasapi.model.NeedsGradingCount)1 LinkHeaders (com.instructure.canvasapi.utilities.LinkHeaders)1 HomeActivity (com.instructure.speedgrader.activities.HomeActivity)1 AssignmentGroupListRecyclerAdapter (com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter)1 AssignmentAdapterToFragmentCallback (com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 Response (retrofit.client.Response)1