use of java.security.InvalidParameterException in project Remindy by abicelis.
the class AttachmentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
Attachment current = mAttachments.get(position);
switch(current.getType()) {
case TEXT:
TextAttachmentViewHolder tvh = (TextAttachmentViewHolder) holder;
tvh.setData(this, mActivity, (TextAttachment) current, position, mRealTimeDataPersistence);
tvh.setListeners();
break;
case LIST:
ListAttachmentViewHolder listvh = (ListAttachmentViewHolder) holder;
listvh.setData(this, mActivity, (ListAttachment) current, position, mRealTimeDataPersistence);
listvh.setListeners();
break;
case LINK:
LinkAttachmentViewHolder lvh = (LinkAttachmentViewHolder) holder;
lvh.setData(this, mActivity, (LinkAttachment) current, position, mRealTimeDataPersistence);
lvh.setListeners();
break;
case AUDIO:
AudioAttachmentViewHolder avh = (AudioAttachmentViewHolder) holder;
avh.setData(this, mActivity, (AudioAttachment) current, position, mRealTimeDataPersistence);
//avh.setListeners();
break;
case IMAGE:
ImageAttachmentViewHolder ivh = (ImageAttachmentViewHolder) holder;
ivh.setData(this, mActivity, (ImageAttachment) current, position, mRealTimeDataPersistence);
ivh.setListeners();
break;
default:
throw new InvalidParameterException("Wrong viewType passed to onCreateViewHolder in AttachmentAdapter");
}
}
use of java.security.InvalidParameterException in project Remindy by abicelis.
the class TaskUtil method getRepeatingReminderNextCalendar.
public static Calendar getRepeatingReminderNextCalendar(RepeatingReminder repeatingReminder) {
Calendar today = Calendar.getInstance();
Calendar endDate = getRepeatingReminderEndCalendar(repeatingReminder);
Calendar cal = CalendarUtil.getCalendarFromDateAndTime(repeatingReminder.getDate(), repeatingReminder.getTime());
while (true) {
if (//If cal passed endDate, reminder is overdue, return null
cal.compareTo(endDate) >= 0)
return null;
if (cal.compareTo(today) >= 0) {
return cal;
}
//cal.add(dateField, repeatingReminder.getRepeatInterval()); break;
switch(repeatingReminder.getRepeatType()) {
case DAILY:
cal.add(Calendar.DAY_OF_WEEK, repeatingReminder.getRepeatInterval());
break;
case WEEKLY:
cal.add(Calendar.WEEK_OF_YEAR, repeatingReminder.getRepeatInterval());
break;
case MONTHLY:
cal.add(Calendar.MONTH, repeatingReminder.getRepeatInterval());
break;
case YEARLY:
cal.add(Calendar.YEAR, repeatingReminder.getRepeatInterval());
break;
default:
throw new InvalidParameterException("Invalid RepeatType parameter in TaskUtil.getRepeatingReminderEndCalendar()");
}
}
}
use of java.security.InvalidParameterException in project Remindy by abicelis.
the class TaskSortingUtil method generateProgrammedTaskHeaderList.
/* Programmed Tasks */
public ArrayList<TaskViewModel> generateProgrammedTaskHeaderList(List<Task> tasks, TaskSortType sortType, Resources resources) throws InvalidClassException {
ArrayList<TaskViewModel> result = new ArrayList<>();
clearTaskBuckets();
if (sortType == TaskSortType.DATE) {
//TODO: this comparator needs to take into account the RepeatingReminder's "next" event date to sort Tasks with RepeatingReminders properly
Collections.sort(tasks, new TasksByReminderDateComparator());
for (Task current : tasks) {
if (current.getReminderType() == null)
throw new NullPointerException("NULL ReminderType passed into TaskSortingUtil.generateProgrammedTaskHeaderList()");
switch(current.getReminderType()) {
case NONE:
throw new InvalidClassException("Wrong ReminderType passed into TaskSortingUtil.generateProgrammedTaskHeaderList()");
case LOCATION_BASED:
tasksLocationBased.add(current);
break;
case ONE_TIME:
insertProgrammedTaskIntoBucket(current, TaskUtil.getReminderEndCalendar(current.getReminder()));
break;
case REPEATING:
insertProgrammedTaskIntoBucket(current, TaskUtil.getRepeatingReminderNextCalendar(((RepeatingReminder) current.getReminder())));
break;
default:
throw new InvalidParameterException("Unhandled ReminderType passed into TaskSortingUtil.generateProgrammedTaskHeaderList()");
}
}
if (tasksOverdue.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_overdue), true));
dumpTaskBucketIntoViewModelList(tasksOverdue, result);
}
if (tasksLocationBased.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_location_based), false));
dumpTaskBucketIntoViewModelList(tasksLocationBased, result);
}
if (tasksToday.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_today), false));
dumpTaskBucketIntoViewModelList(tasksToday, result);
}
if (tasksTomorrow.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_tomorrow), false));
dumpTaskBucketIntoViewModelList(tasksTomorrow, result);
}
if (tasksThisWeek.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_this_week), false));
dumpTaskBucketIntoViewModelList(tasksThisWeek, result);
}
if (tasksNextWeek.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_next_week), false));
dumpTaskBucketIntoViewModelList(tasksNextWeek, result);
}
if (tasksThisMonth.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_this_month), false));
dumpTaskBucketIntoViewModelList(tasksThisMonth, result);
}
if (tasksNextMonth.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_next_month), false));
dumpTaskBucketIntoViewModelList(tasksNextMonth, result);
}
if (tasksThisYear.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_this_year), false));
dumpTaskBucketIntoViewModelList(tasksThisYear, result);
}
if (tasksNextYear.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_next_year), false));
dumpTaskBucketIntoViewModelList(tasksNextYear, result);
}
if (tasksFuture.size() > 0) {
result.add(new TaskViewModel(resources.getString(R.string.task_header_future), false));
dumpTaskBucketIntoViewModelList(tasksFuture, result);
}
} else if (sortType == TaskSortType.PLACE) {
handleSortingByPlace(tasks, result, resources);
}
return result;
}
use of java.security.InvalidParameterException in project Remindy by abicelis.
the class Time method setTimeInMinutes.
public void setTimeInMinutes(int minutes) {
if (minutes >= 0 && minutes <= 24 * 60) {
this.hour = minutes / 60;
this.minute = minutes % 60;
} else
throw new InvalidParameterException("Value of parameter (" + minute + "), is outside 0-60");
}
use of java.security.InvalidParameterException in project Remindy by abicelis.
the class Weekdays method setIntValue.
public void setIntValue(int intValue) {
if (intValue < 0)
throw new InvalidParameterException("Invalid negative intValue");
if (intValue > 127)
throw new InvalidParameterException("Invalid intValue > 127");
value.clear();
for (int i = 6; i >= 0; i--) {
int divisor = (int) Math.pow(2, i);
if (intValue >= divisor) {
value.set(i, true);
intValue = intValue % divisor;
}
}
}
Aggregations