Make filtered MemoryHabitLists update automatically

This commit is contained in:
2017-06-20 10:34:21 -04:00
parent 71fe6137be
commit 00660d3e36
6 changed files with 177 additions and 78 deletions

View File

@@ -92,6 +92,8 @@ public class SQLiteHabitList extends HabitList
record.copyFrom(habit);
record.position = list.indexOf(habit);
repository.save(record);
getObservable().notifyListeners();
}
@Override
@@ -177,20 +179,21 @@ public class SQLiteHabitList extends HabitList
repository.remove(record);
});
rebuildOrder();
getObservable().notifyListeners();
}
@Override
public synchronized void removeAll()
{
loadRecords();
list.removeAll();
SQLiteDatabase db = DatabaseUtils.openDatabase();
db.execSQL("delete from habits");
db.execSQL("delete from repetitions");
getObservable().notifyListeners();
}
@Override
public synchronized void reorder(Habit from, Habit to)
public synchronized void reorder(@NonNull Habit from, @NonNull Habit to)
{
loadRecords();
list.reorder(from, to);
@@ -222,6 +225,7 @@ public class SQLiteHabitList extends HabitList
fromRecord.position = toPos;
repository.save(fromRecord);
update(from);
getObservable().notifyListeners();
}
@@ -251,6 +255,8 @@ public class SQLiteHabitList extends HabitList
record.copyFrom(h);
repository.save(record);
}
getObservable().notifyListeners();
}
public void reload()