mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Merge pull request #348 from llunak/fix_synchronized
synchronize HabitList properly
This commit is contained in:
@@ -155,14 +155,14 @@ public class MemoryHabitList extends HabitList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int indexOf(@NonNull Habit h)
|
public synchronized int indexOf(@NonNull Habit h)
|
||||||
{
|
{
|
||||||
return list.indexOf(h);
|
return list.indexOf(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Habit> iterator()
|
public synchronized Iterator<Habit> iterator()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableCollection(list).iterator();
|
return Collections.unmodifiableCollection(list).iterator();
|
||||||
}
|
}
|
||||||
@@ -200,13 +200,13 @@ public class MemoryHabitList extends HabitList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public synchronized int size()
|
||||||
{
|
{
|
||||||
return list.size();
|
return list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(List<Habit> habits)
|
public synchronized void update(List<Habit> habits)
|
||||||
{
|
{
|
||||||
resort();
|
resort();
|
||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Habit getById(long id)
|
public synchronized Habit getById(long id)
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.getById(id);
|
return list.getById(id);
|
||||||
@@ -99,7 +99,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public Habit getByPosition(int position)
|
public synchronized Habit getByPosition(int position)
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.getByPosition(position);
|
return list.getByPosition(position);
|
||||||
@@ -107,7 +107,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public HabitList getFiltered(HabitMatcher filter)
|
public synchronized HabitList getFiltered(HabitMatcher filter)
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.getFiltered(filter);
|
return list.getFiltered(filter);
|
||||||
@@ -121,21 +121,21 @@ public class SQLiteHabitList extends HabitList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOrder(@NonNull Order order)
|
public synchronized void setOrder(@NonNull Order order)
|
||||||
{
|
{
|
||||||
list.setOrder(order);
|
list.setOrder(order);
|
||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int indexOf(@NonNull Habit h)
|
public synchronized int indexOf(@NonNull Habit h)
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.indexOf(h);
|
return list.indexOf(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Habit> iterator()
|
public synchronized Iterator<Habit> iterator()
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.iterator();
|
return list.iterator();
|
||||||
@@ -214,7 +214,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void repair()
|
public synchronized void repair()
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
rebuildOrder();
|
rebuildOrder();
|
||||||
@@ -222,7 +222,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public synchronized int size()
|
||||||
{
|
{
|
||||||
loadRecords();
|
loadRecords();
|
||||||
return list.size();
|
return list.size();
|
||||||
@@ -245,7 +245,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload()
|
public synchronized void reload()
|
||||||
{
|
{
|
||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user