use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class SyllabusRecyclerAdapterTest method areContentsTheSame_NullDate.
@Test
public void areContentsTheSame_NullDate() {
ScheduleItem item = new ScheduleItem();
item.setTitle("item");
item.setStartAt(new Date());
ScheduleItem item1 = new ScheduleItem();
item1.setTitle("item");
item1.setStartAt(null);
assertFalse(mAdapter.createItemCallback().areContentsTheSame(item, item1));
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class SyllabusBinder method bind.
public static void bind(final Context context, final SyllabusViewHolder holder, final int courseColor, final ScheduleItem item, final AdapterToFragmentCallback<ScheduleItem> adapterToFragmentCallback) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapterToFragmentCallback.onRowClicked(item, holder.getAdapterPosition(), false);
}
});
switch(item.getItemType()) {
case TYPE_CALENDAR:
case TYPE_ASSIGNMENT:
holder.title.setText(item.getTitle());
Drawable drawable;
Assignment assignment = item.getAssignment();
if (assignment != null) {
int drawableResId = getAssignmentIcon(assignment);
drawable = ColorKeeper.getColoredDrawable(context, drawableResId, courseColor);
holder.icon.setImageDrawable(drawable);
Date dueDate = assignment.getDueAt();
holder.date.setTextColor(context.getResources().getColor(R.color.secondaryText));
if (dueDate != null) {
String dateString = DateHelper.createPrefixedDateTimeString(context, R.string.toDoDue, dueDate);
holder.date.setText(dateString);
} else {
holder.date.setText(context.getResources().getString(R.string.toDoNoDueDate));
}
String description = getHtmlAsText(assignment.getDescription());
setCleanText(holder.description, description);
if (TextUtils.isEmpty(description))
holder.description.setVisibility(View.GONE);
else
holder.description.setVisibility(View.VISIBLE);
// currently submissions aren't returned for the syllabus fragment, so points will be null.
setGone(holder.points);
} else {
drawable = ColorKeeper.getColoredDrawable(context, R.drawable.vd_calendar, courseColor);
holder.icon.setImageDrawable(drawable);
setCleanText(holder.date, item.getStartDateString(context));
String description = getHtmlAsText(item.getDescription());
setCleanText(holder.description, description);
if (TextUtils.isEmpty(description))
holder.description.setVisibility(View.GONE);
else
holder.description.setVisibility(View.VISIBLE);
holder.points.setText("");
}
break;
default:
Logger.d("UNSUPPORTED TYPE FOUND IN SYLLABUS BINDER");
break;
}
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class ScheduleItemBinder method bind.
public static void bind(final ScheduleItemViewHolder holder, final ScheduleItem item, final Context context, final int courseColor, final String contextName, final AdapterToFragmentCallback<ScheduleItem> adapterToFragmentCallback) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapterToFragmentCallback.onRowClicked(item, holder.getAdapterPosition(), false);
}
});
switch(item.getItemType()) {
case TYPE_SYLLABUS:
{
holder.title.setText(context.getString(R.string.syllabus));
Drawable drawable = ColorKeeper.getColoredDrawable(context, R.drawable.vd_syllabus, courseColor);
holder.icon.setImageDrawable(drawable);
break;
}
case TYPE_CALENDAR:
{
Drawable drawable = ColorKeeper.getColoredDrawable(context, R.drawable.vd_calendar, courseColor);
holder.icon.setImageDrawable(drawable);
holder.title.setText(item.getTitle());
holder.date.setText(item.getStartString(context));
String description = getHtmlAsText(item.getDescription());
setupDescription(description, holder.description);
break;
}
case TYPE_ASSIGNMENT:
holder.title.setText(item.getTitle());
Drawable drawable;
Assignment assignment = item.getAssignment();
if (assignment != null) {
final int drawableResId = getAssignmentIcon(assignment);
drawable = ColorKeeper.getColoredDrawable(context, drawableResId, courseColor);
holder.icon.setImageDrawable(drawable);
Date dueDate = assignment.getDueAt();
if (dueDate != null) {
String dateString = DateHelper.createPrefixedDateTimeString(context, R.string.toDoDue, dueDate);
holder.date.setText(dateString);
} else {
holder.date.setText(context.getResources().getString(R.string.toDoNoDueDate));
}
String description = getHtmlAsText(assignment.getDescription());
setupDescription(description, holder.description);
// submissions aren't included with the assignments in the api call, so we don't get grades
// so we'll never see the grade
setInvisible(holder.points);
} else {
drawable = ColorKeeper.getColoredDrawable(context, R.drawable.vd_calendar, courseColor);
holder.icon.setImageDrawable(drawable);
holder.date.setText(item.getStartString(context));
String description = getHtmlAsText(item.getDescription());
setupDescription(description, holder.description);
}
break;
}
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class CalendarEventManager method getCalendarEventsExhaustive.
public static void getCalendarEventsExhaustive(final boolean allEvents, @NonNull final CalendarEventAPI.CalendarEventType type, @Nullable final String startDate, @Nullable final String endDate, @NonNull final List<String> canvasContexts, @NonNull StatusCallback<List<ScheduleItem>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
CalendarEventManager_Test.getCalendarEvents(callback);
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
StatusCallback<List<ScheduleItem>> exhaustiveCallback = new ExhaustiveListCallback<ScheduleItem>(callback) {
@Override
public void getNextPage(@NonNull StatusCallback<List<ScheduleItem>> callback, @NonNull String nextUrl, boolean isCached) {
CalendarEventAPI.getCalendarEvents(allEvents, type, startDate, endDate, canvasContexts, adapter, callback, params);
}
};
adapter.setStatusCallback(exhaustiveCallback);
CalendarEventAPI.getCalendarEvents(allEvents, type, startDate, endDate, canvasContexts, adapter, exhaustiveCallback, params);
}
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class CalendarEventManager method getUpcomingEvents.
public static void getUpcomingEvents(StatusCallback<List<ScheduleItem>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).build();
CalendarEventAPI.getUpcomingEvents(adapter, params, callback);
}
}
Aggregations