Only recalculate all list positions when repairing database

pull/201/head
Alinson S. Xavier 9 years ago
parent 919504ccfb
commit f876fc50bb

@ -27,6 +27,7 @@ import org.isoron.uhabits.activities.habits.list.controllers.*;
import org.isoron.uhabits.activities.habits.list.model.*; import org.isoron.uhabits.activities.habits.list.model.*;
import org.isoron.uhabits.commands.*; import org.isoron.uhabits.commands.*;
import org.isoron.uhabits.models.*; import org.isoron.uhabits.models.*;
import org.isoron.uhabits.models.sqlite.*;
import org.isoron.uhabits.preferences.*; import org.isoron.uhabits.preferences.*;
import org.isoron.uhabits.tasks.*; import org.isoron.uhabits.tasks.*;
import org.isoron.uhabits.utils.*; import org.isoron.uhabits.utils.*;
@ -159,11 +160,19 @@ public class ListHabitsController
public void onRepairDB() public void onRepairDB()
{ {
taskRunner.execute(() -> { taskRunner.execute(() -> {
for(Habit h : habitList) { for(Habit h : habitList)
{
h.getCheckmarks().invalidateNewerThan(0); h.getCheckmarks().invalidateNewerThan(0);
h.getStreaks().invalidateNewerThan(0); h.getStreaks().invalidateNewerThan(0);
h.getScores().invalidateNewerThan(0); h.getScores().invalidateNewerThan(0);
} }
if(habitList instanceof SQLiteHabitList)
{
SQLiteHabitList sqlList = (SQLiteHabitList) habitList;
sqlList.rebuildOrder();
}
screen.showMessage(R.string.database_repaired); screen.showMessage(R.string.database_repaired);
}); });
} }

@ -210,10 +210,7 @@ public class SQLiteHabitList extends HabitList
fromRecord.position = toPos; fromRecord.position = toPos;
fromRecord.save(); fromRecord.save();
update(from); update(from);
rebuildOrder();
getObservable().notifyListeners(); getObservable().notifyListeners();
} }

Loading…
Cancel
Save