Show empty message at startup

pull/151/head
Alinson S. Xavier 9 years ago
parent cb3b8f2cde
commit 33ae8d1edf

@ -199,6 +199,12 @@ public class HabitCardListAdapter
observable.notifyListeners(); observable.notifyListeners();
} }
@Override
public void onRefreshFinished()
{
observable.notifyListeners();
}
/** /**
* Removes a list of habits from the adapter. * Removes a list of habits from the adapter.
* <p> * <p>

@ -190,6 +190,8 @@ public class HabitCardListCache implements CommandRunner.Listener
default void onItemMoved(int oldPosition, int newPosition) {} default void onItemMoved(int oldPosition, int newPosition) {}
default void onItemRemoved(int position) {} default void onItemRemoved(int position) {}
default void onRefreshFinished() {}
} }
private class CacheData private class CacheData
@ -319,6 +321,7 @@ public class HabitCardListCache implements CommandRunner.Listener
public void onPostExecute() public void onPostExecute()
{ {
currentFetchTask = null; currentFetchTask = null;
listener.onRefreshFinished();
} }
@Override @Override

@ -70,7 +70,7 @@ public class MemoryHabitList extends HabitList
return null; return null;
} }
@Nullable @NonNull
@Override @Override
public Habit getByPosition(int position) public Habit getByPosition(int position)
{ {

@ -41,7 +41,7 @@ public class SQLiteHabitList extends HabitList
private final SQLiteUtils<HabitRecord> sqlite; private final SQLiteUtils<HabitRecord> sqlite;
private ModelFactory modelFactory; private final ModelFactory modelFactory;
public SQLiteHabitList(@NonNull ModelFactory modelFactory) public SQLiteHabitList(@NonNull ModelFactory modelFactory)
{ {
@ -52,9 +52,12 @@ public class SQLiteHabitList extends HabitList
sqlite = new SQLiteUtils<>(HabitRecord.class); sqlite = new SQLiteUtils<>(HabitRecord.class);
} }
protected SQLiteHabitList(@NonNull HabitMatcher filter) protected SQLiteHabitList(@NonNull ModelFactory modelFactory,
@NonNull HabitMatcher filter)
{ {
super(filter); super(filter);
this.modelFactory = modelFactory;
if (cache == null) cache = new HashMap<>(); if (cache == null) cache = new HashMap<>();
sqlite = new SQLiteUtils<>(HabitRecord.class); sqlite = new SQLiteUtils<>(HabitRecord.class);
} }
@ -105,7 +108,7 @@ public class SQLiteHabitList extends HabitList
} }
@Override @Override
@Nullable @NonNull
public Habit getByPosition(int position) public Habit getByPosition(int position)
{ {
return toList().get(position); return toList().get(position);
@ -115,7 +118,7 @@ public class SQLiteHabitList extends HabitList
@Override @Override
public HabitList getFiltered(HabitMatcher filter) public HabitList getFiltered(HabitMatcher filter)
{ {
return new SQLiteHabitList(filter); return new SQLiteHabitList(modelFactory, filter);
} }
@Override @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); null);
verify(listener).onItemRemoved(0); verify(listener).onItemRemoved(0);
verify(listener).onRefreshFinished();
assertThat(cache.getHabitCount(), equalTo(9)); assertThat(cache.getHabitCount(), equalTo(9));
} }
@ -94,6 +95,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
h2.getId()); h2.getId());
verify(listener).onItemChanged(2); verify(listener).onItemChanged(2);
verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener); verifyNoMoreInteractions(listener);
} }
@ -128,9 +130,18 @@ public class HabitCardListCacheTest extends BaseUnitTest
cache.refreshAllHabits(); cache.refreshAllHabits();
verify(listener).onItemRemoved(0); verify(listener).onItemRemoved(0);
verify(listener).onItemRemoved(3); verify(listener).onItemRemoved(3);
verify(listener).onRefreshFinished();
assertThat(cache.getHabitCount(), equalTo(8)); assertThat(cache.getHabitCount(), equalTo(8));
} }
@Test
public void testRefreshWithNoChanges()
{
cache.refreshAllHabits();
verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener);
}
@Test @Test
public void testReorder_onCache() public void testReorder_onCache()
{ {
@ -170,6 +181,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
verify(listener).onItemMoved(5, 4); verify(listener).onItemMoved(5, 4);
verify(listener).onItemMoved(6, 5); verify(listener).onItemMoved(6, 5);
verify(listener).onItemMoved(7, 6); verify(listener).onItemMoved(7, 6);
verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener); verifyNoMoreInteractions(listener);
} }

Loading…
Cancel
Save