mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Remove notification when habit is deleted
This commit is contained in:
@@ -42,25 +42,30 @@ public class DeleteHabitsCommand extends Command
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
for(Habit h : habits)
|
||||
for (Habit h : habits)
|
||||
habitList.remove(h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getExecuteStringId()
|
||||
{
|
||||
return R.string.toast_habit_deleted;
|
||||
}
|
||||
|
||||
public List<Habit> getHabits()
|
||||
{
|
||||
return new LinkedList<>(habits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getUndoStringId()
|
||||
{
|
||||
return R.string.toast_habit_restored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,16 +88,25 @@ public class NotificationTray
|
||||
public void onCommandExecuted(@NonNull Command command,
|
||||
@Nullable Long refreshKey)
|
||||
{
|
||||
if (!(command instanceof ToggleRepetitionCommand)) return;
|
||||
|
||||
ToggleRepetitionCommand toggleCommand =
|
||||
if (command instanceof ToggleRepetitionCommand)
|
||||
{
|
||||
ToggleRepetitionCommand toggleCmd =
|
||||
(ToggleRepetitionCommand) command;
|
||||
|
||||
Habit habit = toggleCommand.getHabit();
|
||||
Habit habit = toggleCmd.getHabit();
|
||||
if (habit.getCheckmarks().getTodayValue() != Checkmark.UNCHECKED)
|
||||
cancel(habit);
|
||||
}
|
||||
|
||||
if (command instanceof DeleteHabitsCommand)
|
||||
{
|
||||
DeleteHabitsCommand deleteCommand = (DeleteHabitsCommand) command;
|
||||
List<Habit> deleted = deleteCommand.getHabits();
|
||||
for(Habit habit : deleted)
|
||||
cancel(habit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationsChanged()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user