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:
@@ -46,21 +46,26 @@ public class DeleteHabitsCommand extends Command
|
|||||||
habitList.remove(h);
|
habitList.remove(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getExecuteStringId()
|
public Integer getExecuteStringId()
|
||||||
{
|
{
|
||||||
return R.string.toast_habit_deleted;
|
return R.string.toast_habit_deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Habit> getHabits()
|
||||||
|
{
|
||||||
|
return new LinkedList<>(habits);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getUndoStringId()
|
public Integer getUndoStringId()
|
||||||
{
|
{
|
||||||
return R.string.toast_habit_restored;
|
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,
|
public void onCommandExecuted(@NonNull Command command,
|
||||||
@Nullable Long refreshKey)
|
@Nullable Long refreshKey)
|
||||||
{
|
{
|
||||||
if (!(command instanceof ToggleRepetitionCommand)) return;
|
if (command instanceof ToggleRepetitionCommand)
|
||||||
|
{
|
||||||
ToggleRepetitionCommand toggleCommand =
|
ToggleRepetitionCommand toggleCmd =
|
||||||
(ToggleRepetitionCommand) command;
|
(ToggleRepetitionCommand) command;
|
||||||
|
|
||||||
Habit habit = toggleCommand.getHabit();
|
Habit habit = toggleCmd.getHabit();
|
||||||
if (habit.getCheckmarks().getTodayValue() != Checkmark.UNCHECKED)
|
if (habit.getCheckmarks().getTodayValue() != Checkmark.UNCHECKED)
|
||||||
cancel(habit);
|
cancel(habit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command instanceof DeleteHabitsCommand)
|
||||||
|
{
|
||||||
|
DeleteHabitsCommand deleteCommand = (DeleteHabitsCommand) command;
|
||||||
|
List<Habit> deleted = deleteCommand.getHabits();
|
||||||
|
for(Habit habit : deleted)
|
||||||
|
cancel(habit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationsChanged()
|
public void onNotificationsChanged()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user