Search in sources :

Example 46 with InvalidParameterException

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");
    }
}
Also used : LinkAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.LinkAttachmentViewHolder) InvalidParameterException(java.security.InvalidParameterException) ImageAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder) ListAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ListAttachmentViewHolder) Attachment(ve.com.abicelis.remindy.model.attachment.Attachment) LinkAttachment(ve.com.abicelis.remindy.model.attachment.LinkAttachment) ListAttachment(ve.com.abicelis.remindy.model.attachment.ListAttachment) AudioAttachment(ve.com.abicelis.remindy.model.attachment.AudioAttachment) TextAttachment(ve.com.abicelis.remindy.model.attachment.TextAttachment) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment) AudioAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.AudioAttachmentViewHolder) TextAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.TextAttachmentViewHolder)

Example 47 with InvalidParameterException

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()");
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Calendar(java.util.Calendar)

Example 48 with InvalidParameterException

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;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Task(ve.com.abicelis.remindy.model.Task) TaskViewModel(ve.com.abicelis.remindy.viewmodel.TaskViewModel) TasksByReminderDateComparator(ve.com.abicelis.remindy.model.TasksByReminderDateComparator) InvalidClassException(java.io.InvalidClassException) ArrayList(java.util.ArrayList)

Example 49 with InvalidParameterException

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");
}
Also used : InvalidParameterException(java.security.InvalidParameterException)

Example 50 with InvalidParameterException

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;
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)135 SecureRandom (java.security.SecureRandom)15 ActionEvent (com.cloud.event.ActionEvent)11 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)9 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 Paint (android.graphics.Paint)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 DB (com.cloud.utils.db.DB)7 File (java.io.File)7 Properties (java.util.Properties)7 NimbusClient (backtype.storm.utils.NimbusClient)6 FirewallRule (com.cloud.network.rules.FirewallRule)6 InvalidKeyException (java.security.InvalidKeyException)6 Time (android.text.format.Time)4 FileNotFoundException (java.io.FileNotFoundException)4