You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tasks/app/src/main/java/org/tasks/jobs/AlarmEntry.java

74 lines
1.7 KiB
Java

package org.tasks.jobs;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import static org.tasks.time.DateTimeUtils.printTimestamp;
import com.todoroo.astrid.reminders.ReminderService;
import org.tasks.notifications.Notification;
public class AlarmEntry implements NotificationQueueEntry {
private final long alarmId;
private final long taskId;
private final long time;
public AlarmEntry(long alarmId, long taskId, Long time) {
this.alarmId = alarmId;
this.taskId = taskId;
this.time = time;
}
@Override
public long getId() {
return alarmId;
}
@Override
public long getTime() {
return time;
}
@Override
public Notification toNotification() {
Notification notification = new Notification();
notification.setTaskId(taskId);
notification.setType(ReminderService.TYPE_ALARM);
notification.setTimestamp(currentTimeMillis());
return notification;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AlarmEntry alarmEntry = (AlarmEntry) o;
if (alarmId != alarmEntry.alarmId) {
return false;
}
if (taskId != alarmEntry.taskId) {
return false;
}
return time == alarmEntry.time;
}
@Override
public int hashCode() {
int result = (int) (alarmId ^ (alarmId >>> 32));
result = 31 * result + (int) (taskId ^ (taskId >>> 32));
result = 31 * result + (int) (time ^ (time >>> 32));
return result;
}
@Override
public String toString() {
return "AlarmEntry{" + "alarmId=" + alarmId + ", taskId=" + taskId + ", time=" + printTimestamp(time) + '}';
}
}