Android Open Source - TasksReminder Task






From Project

Back to project page TasksReminder.

License

The source code is released under:

MIT License

If you think the Android project TasksReminder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.sampa.tasksreminder;
/*from  ww  w .j a  v  a2  s .co  m*/
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class Task {

  long id;
  String title, description;
  LocalDate date, dateReminder;
  LocalTime time, timeReminder;
  int frequency;
  /*
   * 0 -> hours 1 -> days 2-> weeks 3 -> months 4 -> years
   */
  byte frequencyUnit;
  boolean dateSet, timeSet, dateReminderSet, timeReminderSet;
  boolean useReminder;

  public Task() {
  }

  public Task(String title, String description, LocalDateTime date) {
    super();
    this.title = title;
    this.description = description;
    this.date = date.toLocalDate();
    this.time = date.toLocalTime();
    this.dateSet = true;
    this.timeSet = true;
    this.useReminder = false;
  }

  public Task(String title, String description, LocalDateTime date,
      LocalDateTime dateReminder, int frequency, byte frequencyUnit) {
    this.title = title;
    this.description = description;
    this.date = date.toLocalDate();
    this.time = date.toLocalTime();
    this.dateReminder = dateReminder.toLocalDate();
    this.timeReminder = dateReminder.toLocalTime();
    this.frequency = frequency;
    this.frequencyUnit = frequencyUnit;
    this.dateSet = true;
    this.timeSet = true;
    this.dateReminderSet = true;
    this.timeReminderSet = true;
    this.useReminder = true;
  }

  public String dateReminderToString() {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("EEEE dd MMMM yyyy");
    return dateReminder.toString(fmt);
  }

  public String dateToString() {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("EEEE dd MMMM yyyy");
    return date.toString(fmt);
  }

  public LocalDateTime getCompleteDate() {
    LocalDateTime date = new LocalDateTime();
    date = date.withFields(this.getDate());
    return date = date.withFields(this.getTime());
  }

  public LocalDateTime getCompleteReminderDate() {
    LocalDateTime date = new LocalDateTime();
    date = date.withFields(this.getReminderDate());
    return date = date.withFields(this.getReminderTime());
  }

  public LocalDate getDate() {
    return date;
  }

  public String getDescription() {
    return description;
  }

  public int getFrequency() {
    return frequency;
  }

  public byte getFrequencyUnit() {
    return frequencyUnit;
  }

  public long getID() {
    return id;
  }

  public LocalDate getReminderDate() {
    return dateReminder;
  }

  public LocalTime getReminderTime() {
    return timeReminder;
  }

  public LocalTime getTime() {
    return time;
  }

  public String getTitle() {
    return title;
  }

  public boolean getUseReminder() {
    return useReminder;
  }

  public boolean isDateReminderSet() {
    return dateReminderSet;
  }

  public boolean isDateSet() {
    return dateSet;
  }

  public boolean isTimeReminderSet() {
    return timeReminderSet;
  }

  public boolean isTimeSet() {
    return timeSet;
  }

  public String reminderDateToString() {
    return dateReminder.toString("EEEE dd MMMM yyyy");
  }

  public void setDate(LocalDate dateSelected) {
    dateSet = true;
    this.date = dateSelected;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public void setFrequency(int frequency) {
    this.frequency = frequency;
  }

  public void setFrequencyUnit(byte frequencyUnit) {
    this.frequencyUnit = frequencyUnit;
  }

  public void setID(long id) {
    this.id = id;
  }

  public LocalDateTime setNextAlarm() {
    LocalDateTime date = getCompleteReminderDate();
    switch (frequencyUnit) {
    case 0:
      date = date.plusHours(getFrequency());
      break;
    case 1:
      date = date.plusDays(getFrequency());
      break;
    case 2:
      date = date.plusWeeks(getFrequency());
      break;
    case 3:
      date = date.plusMonths(getFrequency());
      break;
    case 4:
      date = date.plusYears(getFrequency());
      break;
    }

    if (date.isAfter(getCompleteDate())) {
      useReminder = false;
      return null;
    }

    dateReminder = date.toLocalDate();
    timeReminder = date.toLocalTime();
    return date;
  }

  public void setReminderDate(LocalDate reminderSelected) {
    dateReminderSet = true;
    this.dateReminder = reminderSelected;
  }

  public void setReminderTime(int hour, int minute) {
    timeReminderSet = true;
    timeReminder = new LocalTime(hour, minute);
  }

  public void setTime(int hour, int minute) {
    timeSet = true;
    time = new LocalTime(hour, minute);
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public void setUseReminder(boolean useReminder) {
    this.useReminder = useReminder;
  }

  public String timeReminderToString() {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm");
    return timeReminder.toString(fmt);
  }

  public String timeToString() {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm");
    return time.toString(fmt);
  }

}




Java Source Code List

com.sampa.tasksreminder.AlarmManagerHelper.java
com.sampa.tasksreminder.AlarmReceiver.java
com.sampa.tasksreminder.AlarmService.java
com.sampa.tasksreminder.DatePickerActivity.java
com.sampa.tasksreminder.DatePickerActivity_.java
com.sampa.tasksreminder.MainActivity.java
com.sampa.tasksreminder.MainActivity_.java
com.sampa.tasksreminder.NewTaskActivity.java
com.sampa.tasksreminder.NewTaskActivity_.java
com.sampa.tasksreminder.ShowTaskActivity.java
com.sampa.tasksreminder.ShowTaskActivity_.java
com.sampa.tasksreminder.TaskCursorAdapter.java
com.sampa.tasksreminder.TaskSQLiteHelper.java
com.sampa.tasksreminder.Task.java
com.sampa.tasksreminder.TimePickerFragment.java
com.sampa.tasksreminder.TimePickerFragment_.java
com.squareup.timessquare.CalendarCellView.java
com.squareup.timessquare.CalendarGridView.java
com.squareup.timessquare.CalendarPickerView.java
com.squareup.timessquare.CalendarRowView.java
com.squareup.timessquare.Logr.java
com.squareup.timessquare.MonthCellDescriptor.java
com.squareup.timessquare.MonthDescriptor.java
com.squareup.timessquare.MonthView.java