Browse Source

added help text when no favourite

develop
Robin Thoni 7 years ago
parent
commit
d5c82037f1

+ 9
- 0
app/src/main/java/com/rthoni/stssaguenay/ui/fragments/HomeFragment.java View File

@@ -47,6 +47,9 @@ public class HomeFragment extends Fragment {
47 47
     @BindView(R.id.swipeContainer)
48 48
     SwipeRefreshLayout _swipeRefreshLayout;
49 49
 
50
+    @BindView(R.id.textHelp)
51
+    TextView _textHelp;
52
+
50 53
     private FavouriteStopsAdapter _adapter;
51 54
 
52 55
     private LuConsumer<UserFavouriteStopsDbo> _onFavouriteStopClicked;
@@ -182,6 +185,7 @@ public class HomeFragment extends Fragment {
182 185
     public void loadFavourites()
183 186
     {
184 187
         List<UserFavouriteStopsDbo> favourites = STSBusiness.getFavouriteStops(getContext());
188
+        _textHelp.setVisibility(favourites.size() == 0 ? View.VISIBLE : View.GONE);
185 189
         _adapter.setFavourites(favourites);
186 190
         loadSchedules();
187 191
     }
@@ -219,6 +223,11 @@ public class HomeFragment extends Fragment {
219 223
 
220 224
     public void loadSchedules()
221 225
     {
226
+        if (_adapter.getFavourites().size() == 0)
227
+        {
228
+            setRefreshing(false);
229
+            return;
230
+        }
222 231
         setRefreshing(true);
223 232
         _adapter.setSchedules(null);
224 233
         TimeZone tz = TimeZone.getDefault();

+ 15
- 11
app/src/main/res/layout/fragment_home.xml View File

@@ -11,29 +11,33 @@
11 11
         android:id="@+id/textView"
12 12
         android:text="@string/favourites_stops"
13 13
         android:layout_alignParentTop="true"
14
-        android:layout_alignParentLeft="true"
15 14
         android:layout_alignParentStart="true"
16
-        android:layout_alignParentRight="true"
17 15
         android:layout_alignParentEnd="true"/>
18 16
 
19
-    <android.support.v4.widget.SwipeRefreshLayout
20
-        xmlns:android="http://schemas.android.com/apk/res/android"
21
-        android:id="@+id/swipeContainer"
22
-        android:layout_width="match_parent"
23
-        android:layout_height="match_parent"
17
+    <TextView
18
+        android:text="@string/favourite_none"
19
+        android:layout_width="wrap_content"
20
+        android:layout_height="wrap_content"
21
+        android:id="@+id/textHelp"
24 22
         android:layout_below="@+id/textView"
25
-        android:layout_alignParentLeft="true"
26 23
         android:layout_alignParentStart="true"
27
-        android:layout_alignParentRight="true"
28 24
         android:layout_alignParentEnd="true"
29
-        android:layout_alignParentBottom="true">
25
+        android:gravity="center_horizontal"/>
26
+
27
+    <android.support.v4.widget.SwipeRefreshLayout
28
+        xmlns:android="http://schemas.android.com/apk/res/android"
29
+        android:id="@+id/swipeContainer"
30
+        android:layout_width="wrap_content"
31
+        android:layout_height="wrap_content"
32
+        android:layout_below="@+id/textHelp">
30 33
 
31 34
         <android.support.v7.widget.RecyclerView
32 35
             android:layout_width="wrap_content"
33 36
             android:layout_height="wrap_content"
34 37
             android:id="@+id/listFavouritesStops"
35 38
             android:scrollbars="vertical"
36
-            android:fadeScrollbars="true"/>
39
+            android:fadeScrollbars="true"
40
+            android:layout_alignParentBottom="true"/>
37 41
 
38 42
     </android.support.v4.widget.SwipeRefreshLayout>
39 43
 </RelativeLayout>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@@ -21,6 +21,7 @@
21 21
     <string name="loading_routes">Loading routes&#8230;</string>
22 22
     <string name="loading_stops">Loading stops&#8230;</string>
23 23
 
24
+    <string name="favourite_none">You don\'t have any favourite yet.\nUse the + button to add one, or search a stop using the left menu without adding it to your favourites</string>
24 25
     <string name="favourite_remove">Remove favourite</string>
25 26
     <string name="favourite_remove_confirm">Do you really want to remove %1$s?</string>
26 27
     <string name="favourite_removed">%1$s has been removed</string>

Loading…
Cancel
Save