mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Remove ModelObservable from RepetitionList
This commit is contained in:
@@ -30,13 +30,9 @@ public abstract class RepetitionList
|
||||
@NonNull
|
||||
protected final Habit habit;
|
||||
|
||||
@NonNull
|
||||
protected final ModelObservable observable;
|
||||
|
||||
public RepetitionList(@NonNull Habit habit)
|
||||
{
|
||||
this.habit = habit;
|
||||
this.observable = new ModelObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,12 +82,6 @@ public abstract class RepetitionList
|
||||
return check.getValue();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ModelObservable getObservable()
|
||||
{
|
||||
return observable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the oldest checkmark in the list.
|
||||
* <p>
|
||||
|
||||
@@ -42,7 +42,6 @@ public class MemoryRepetitionList extends RepetitionList
|
||||
public void add(Entry repetition)
|
||||
{
|
||||
list.add(repetition);
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,7 +114,6 @@ public class MemoryRepetitionList extends RepetitionList
|
||||
public void remove(@NonNull Entry repetition)
|
||||
{
|
||||
list.remove(repetition);
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,6 +130,5 @@ public class MemoryRepetitionList extends RepetitionList
|
||||
public void removeAll()
|
||||
{
|
||||
list.clear();
|
||||
getObservable().notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ public class SQLiteRepetitionList extends RepetitionList
|
||||
record.habit_id = habit.getId();
|
||||
record.copyFrom(entry);
|
||||
repository.save(record);
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +115,6 @@ public class SQLiteRepetitionList extends RepetitionList
|
||||
repository.execSQL(
|
||||
"delete from repetitions where habit = ? and timestamp = ?",
|
||||
habit.getId(), entry.getTimestamp().getUnixTime());
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
public void removeAll()
|
||||
|
||||
@@ -31,7 +31,6 @@ import static java.util.Calendar.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.IsEqual.*;
|
||||
import static org.isoron.uhabits.core.models.Entry.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class RepetitionListTest extends BaseUnitTest
|
||||
{
|
||||
@@ -45,9 +44,6 @@ public class RepetitionListTest extends BaseUnitTest
|
||||
|
||||
private long day;
|
||||
|
||||
@NonNull
|
||||
private ModelObservable.Listener listener;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
@@ -63,10 +59,6 @@ public class RepetitionListTest extends BaseUnitTest
|
||||
reps.setValue(today, YES_MANUAL);
|
||||
reps.setValue(today.minus(7), YES_MANUAL);
|
||||
reps.setValue(today.minus(5), YES_MANUAL);
|
||||
|
||||
listener = mock(ModelObservable.Listener.class);
|
||||
reps.getObservable().addListener(listener);
|
||||
reset(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,18 +139,12 @@ public class RepetitionListTest extends BaseUnitTest
|
||||
assertThat(reps.getValue(today), equalTo(YES_MANUAL));
|
||||
reps.setValue(today, NO);
|
||||
assertThat(reps.getValue(today), equalTo(NO));
|
||||
verify(listener, times(2)).onModelChange();
|
||||
reset(listener);
|
||||
|
||||
habit.setType(Habit.NUMBER_HABIT);
|
||||
reps.setValue(today, 100);
|
||||
assertThat(reps.getValue(today), equalTo(100));
|
||||
verify(listener, times(2)).onModelChange();
|
||||
reset(listener);
|
||||
|
||||
reps.setValue(today, 500);
|
||||
assertThat(reps.getValue(today), equalTo(500));
|
||||
verify(listener, times(2)).onModelChange();
|
||||
reset(listener);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user