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());
}
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;
}
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;
}
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());
}
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;
}
Aggregations