use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.
the class DetailViewActivity method routeFromIntent.
private void routeFromIntent(Intent intent) {
DETAIL_FRAGMENT fragmentType = (DETAIL_FRAGMENT) intent.getExtras().getSerializable(Const.FRAGMENT_TYPE);
if (fragmentType != null) {
Student student = intent.getExtras().getParcelable(Const.STUDENT);
switch(fragmentType) {
case WEEK:
Student user = intent.getExtras().getParcelable(Const.USER);
Course course = (Course) intent.getExtras().getSerializable(Const.COURSE);
if (user != null && course != null) {
addFragment(CourseWeekFragment.newInstance(user, course));
}
break;
case ASSIGNMENT:
Assignment assignment = intent.getExtras().getParcelable(Const.ASSIGNMENT);
String courseName = intent.getExtras().getString(Const.NAME);
addFragment(AssignmentFragment.newInstance(assignment, courseName, student), false);
break;
case ANNOUNCEMENT:
DiscussionTopicHeader announcement = intent.getExtras().getParcelable(Const.ANNOUNCEMENT);
String announcementCourseName = intent.getExtras().getString(Const.NAME);
addFragment(AnnouncementFragment.newInstance(announcement, announcementCourseName, student), false);
break;
case EVENT:
ScheduleItem item = intent.getExtras().getParcelable(Const.SCHEDULE_ITEM);
addFragment(EventFragment.newInstance(item, student), false);
break;
case SYLLABUS:
Course syllabusCourse = (Course) intent.getExtras().getSerializable(Const.COURSE);
addFragment(CourseSyllabusFragment.newInstance(syllabusCourse, student), false);
break;
case ACCOUNT_NOTIFICATION:
AccountNotification accountNotification = intent.getExtras().getParcelable(Const.ACCOUNT_NOTIFICATION);
addFragment(AccountNotificationFragment.newInstance(accountNotification, student));
}
}
}
use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.
the class ComposeNewDiscussionFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
applyTheme();
if (isAnnouncement) {
threaded.setVisibility(View.GONE);
publish.setVisibility(View.GONE);
} else {
threaded.setVisibility(View.VISIBLE);
publish.setVisibility(View.VISIBLE);
}
if (getCanvasContext() instanceof Course) {
Course course = (Course) getCanvasContext();
if (((course.isStudent() && !course.isTeacher()))) {
// Students cannot post draft discussions.
// We force it checked for when the api call is made and hide the option.
publish.setChecked(true);
publish.setVisibility(View.GONE);
}
} else if (getCanvasContext() instanceof Group) {
// Always publish for groups
publish.setChecked(true);
publish.setVisibility(View.GONE);
}
setUpCallback();
if (discussionTopicHeader != null) {
populateViewsWithData();
} else {
// clear out views
initViews();
}
}
use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.
the class DiscussionListRecyclerAdapterTest method testAreContentsTheSame_SameTitle.
@Test
public void testAreContentsTheSame_SameTitle() {
DiscussionTopicHeader discussionTopicHeader = new DiscussionTopicHeader();
discussionTopicHeader.setTitle("discussion");
assertTrue(mAdapter.createItemCallback().areContentsTheSame(discussionTopicHeader, discussionTopicHeader));
}
use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.
the class DiscussionListRecyclerAdapterTest method testCompare_bothHaveNullDates.
// region Compare tests
@Test
public void testCompare_bothHaveNullDates() {
DiscussionTopicHeader onlyTitle1 = new DiscussionTopicHeader();
onlyTitle1.setTitle("discussion1");
DiscussionTopicHeader onlyTitle2 = new DiscussionTopicHeader();
onlyTitle2.setTitle("discussion2");
assertEquals(-1, mAdapter.createItemCallback().compare("", onlyTitle1, onlyTitle2));
assertEquals(1, mAdapter.createItemCallback().compare("", onlyTitle2, onlyTitle1));
assertEquals(0, mAdapter.createItemCallback().compare("", onlyTitle1, onlyTitle1));
}
use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.
the class DiscussionListRecyclerAdapterTest method testCompare_oneNullDatePostedAt.
@Test
public void testCompare_oneNullDatePostedAt() {
DiscussionTopicHeader d1 = new DiscussionTopicHeader();
d1.setTitle("discussion1");
DateTime dateTime2 = new DateTime("2014-12-29");
Date date = new Date(dateTime2.getMilliseconds(TimeZone.getDefault()));
d1.setPostedAt(APIHelper.dateToString(date));
DiscussionTopicHeader d2 = new DiscussionTopicHeader();
d2.setTitle("discussion2");
assertEquals(-1, mAdapter.createItemCallback().compare("", d1, d2));
assertEquals(1, mAdapter.createItemCallback().compare("", d2, d1));
assertEquals(0, mAdapter.createItemCallback().compare("", d1, d1));
}
Aggregations