mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Show empty message at startup
This commit is contained in:
@@ -199,6 +199,12 @@ public class HabitCardListAdapter
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFinished()
|
||||
{
|
||||
observable.notifyListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of habits from the adapter.
|
||||
* <p>
|
||||
|
||||
@@ -190,6 +190,8 @@ public class HabitCardListCache implements CommandRunner.Listener
|
||||
default void onItemMoved(int oldPosition, int newPosition) {}
|
||||
|
||||
default void onItemRemoved(int position) {}
|
||||
|
||||
default void onRefreshFinished() {}
|
||||
}
|
||||
|
||||
private class CacheData
|
||||
@@ -319,6 +321,7 @@ public class HabitCardListCache implements CommandRunner.Listener
|
||||
public void onPostExecute()
|
||||
{
|
||||
currentFetchTask = null;
|
||||
listener.onRefreshFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MemoryHabitList extends HabitList
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNull
|
||||
@Override
|
||||
public Habit getByPosition(int position)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SQLiteHabitList extends HabitList
|
||||
|
||||
private final SQLiteUtils<HabitRecord> sqlite;
|
||||
|
||||
private ModelFactory modelFactory;
|
||||
private final ModelFactory modelFactory;
|
||||
|
||||
public SQLiteHabitList(@NonNull ModelFactory modelFactory)
|
||||
{
|
||||
@@ -52,9 +52,12 @@ public class SQLiteHabitList extends HabitList
|
||||
sqlite = new SQLiteUtils<>(HabitRecord.class);
|
||||
}
|
||||
|
||||
protected SQLiteHabitList(@NonNull HabitMatcher filter)
|
||||
protected SQLiteHabitList(@NonNull ModelFactory modelFactory,
|
||||
@NonNull HabitMatcher filter)
|
||||
{
|
||||
super(filter);
|
||||
this.modelFactory = modelFactory;
|
||||
|
||||
if (cache == null) cache = new HashMap<>();
|
||||
sqlite = new SQLiteUtils<>(HabitRecord.class);
|
||||
}
|
||||
@@ -105,7 +108,7 @@ public class SQLiteHabitList extends HabitList
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@NonNull
|
||||
public Habit getByPosition(int position)
|
||||
{
|
||||
return toList().get(position);
|
||||
@@ -115,7 +118,7 @@ public class SQLiteHabitList extends HabitList
|
||||
@Override
|
||||
public HabitList getFiltered(HabitMatcher filter)
|
||||
{
|
||||
return new SQLiteHabitList(filter);
|
||||
return new SQLiteHabitList(modelFactory, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.activities.habits.list.model;
|
||||
|
||||
import org.isoron.uhabits.BaseUnitTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HabitCardListAdapterTest extends BaseUnitTest
|
||||
{
|
||||
@Override
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelection() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCount() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetItem() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetItemId() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSelected() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetView() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSelectionEmpty() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnAttached() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnCacheRefresh() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnDetached() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReorder() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetListView() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToggleSelection() throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
|
||||
null);
|
||||
|
||||
verify(listener).onItemRemoved(0);
|
||||
verify(listener).onRefreshFinished();
|
||||
assertThat(cache.getHabitCount(), equalTo(9));
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
|
||||
h2.getId());
|
||||
|
||||
verify(listener).onItemChanged(2);
|
||||
verify(listener).onRefreshFinished();
|
||||
verifyNoMoreInteractions(listener);
|
||||
}
|
||||
|
||||
@@ -128,9 +130,18 @@ public class HabitCardListCacheTest extends BaseUnitTest
|
||||
cache.refreshAllHabits();
|
||||
verify(listener).onItemRemoved(0);
|
||||
verify(listener).onItemRemoved(3);
|
||||
verify(listener).onRefreshFinished();
|
||||
assertThat(cache.getHabitCount(), equalTo(8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshWithNoChanges()
|
||||
{
|
||||
cache.refreshAllHabits();
|
||||
verify(listener).onRefreshFinished();
|
||||
verifyNoMoreInteractions(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReorder_onCache()
|
||||
{
|
||||
@@ -170,6 +181,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
|
||||
verify(listener).onItemMoved(5, 4);
|
||||
verify(listener).onItemMoved(6, 5);
|
||||
verify(listener).onItemMoved(7, 6);
|
||||
verify(listener).onRefreshFinished();
|
||||
verifyNoMoreInteractions(listener);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user