Browse Source

added help text when no favourite

develop
Robin Thoni 8 years ago
parent
commit
d5c82037f1

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

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

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

11
         android:id="@+id/textView"
11
         android:id="@+id/textView"
12
         android:text="@string/favourites_stops"
12
         android:text="@string/favourites_stops"
13
         android:layout_alignParentTop="true"
13
         android:layout_alignParentTop="true"
14
-        android:layout_alignParentLeft="true"
15
         android:layout_alignParentStart="true"
14
         android:layout_alignParentStart="true"
16
-        android:layout_alignParentRight="true"
17
         android:layout_alignParentEnd="true"/>
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
         android:layout_below="@+id/textView"
22
         android:layout_below="@+id/textView"
25
-        android:layout_alignParentLeft="true"
26
         android:layout_alignParentStart="true"
23
         android:layout_alignParentStart="true"
27
-        android:layout_alignParentRight="true"
28
         android:layout_alignParentEnd="true"
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
         <android.support.v7.widget.RecyclerView
34
         <android.support.v7.widget.RecyclerView
32
             android:layout_width="wrap_content"
35
             android:layout_width="wrap_content"
33
             android:layout_height="wrap_content"
36
             android:layout_height="wrap_content"
34
             android:id="@+id/listFavouritesStops"
37
             android:id="@+id/listFavouritesStops"
35
             android:scrollbars="vertical"
38
             android:scrollbars="vertical"
36
-            android:fadeScrollbars="true"/>
39
+            android:fadeScrollbars="true"
40
+            android:layout_alignParentBottom="true"/>
37
 
41
 
38
     </android.support.v4.widget.SwipeRefreshLayout>
42
     </android.support.v4.widget.SwipeRefreshLayout>
39
 </RelativeLayout>
43
 </RelativeLayout>

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

21
     <string name="loading_routes">Loading routes&#8230;</string>
21
     <string name="loading_routes">Loading routes&#8230;</string>
22
     <string name="loading_stops">Loading stops&#8230;</string>
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
     <string name="favourite_remove">Remove favourite</string>
25
     <string name="favourite_remove">Remove favourite</string>
25
     <string name="favourite_remove_confirm">Do you really want to remove %1$s?</string>
26
     <string name="favourite_remove_confirm">Do you really want to remove %1$s?</string>
26
     <string name="favourite_removed">%1$s has been removed</string>
27
     <string name="favourite_removed">%1$s has been removed</string>

Loading…
Cancel
Save