Added empty list message for dashboard

This commit is contained in:
Alexey Kulish 2016-03-17 12:15:23 +03:00
parent 04ebe2ecf8
commit ca67f518fb
4 changed files with 59 additions and 3 deletions

View file

@ -59,6 +59,19 @@
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:fadeScrollbars="true" > android:fadeScrollbars="true" >
</net.osmand.plus.views.controls.DynamicListView> </net.osmand.plus.views.controls.DynamicListView>
<TextView
android:id="@+id/emptyTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="?attr/bg_color"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clickable="true"
android:textSize="@dimen/default_list_text_size_large"
android:visibility="gone"/>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -55,11 +55,26 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="gone" > android:visibility="gone" >
<View <LinearLayout
android:id="@+id/dash_list_background" android:id="@+id/dash_list_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:background="?attr/bg_color" /> android:background="?attr/bg_color"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/emptyTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center"
android:textSize="@dimen/default_list_text_size_large"
android:visibility="gone"/>
</LinearLayout>
<net.osmand.plus.views.controls.DynamicListView <net.osmand.plus.views.controls.DynamicListView
android:id="@+id/dash_list_view" android:id="@+id/dash_list_view"

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="no_map_markers_found">Please add map markers via map</string>
<string name="no_waypoints_found">No waypoints found</string>
<string name="osmo_group_information_desc"> <string name="osmo_group_information_desc">
- Creating a group please give it a name and fill in description\n - Creating a group please give it a name and fill in description\n
- From the application group are created only with Simple type, read more on the website https://osmo.mobi/g/new \n - From the application group are created only with Simple type, read more on the website https://osmo.mobi/g/new \n

View file

@ -36,6 +36,7 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState; import com.github.ksoichiro.android.observablescrollview.ScrollState;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -151,6 +152,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private int mFlexibleBlurSpaceHeight; private int mFlexibleBlurSpaceHeight;
private boolean portrait; private boolean portrait;
private long lastUpOrCancelMotionEventTime; private long lastUpOrCancelMotionEventTime;
private TextView listEmptyTextView;
int baseColor; int baseColor;
@ -218,6 +220,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
//listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); //listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setDrawSelectorOnTop(true); listView.setDrawSelectorOnTop(true);
listView.setDynamicListViewCallbacks(this); listView.setDynamicListViewCallbacks(this);
listEmptyTextView = (TextView) dashboardView.findViewById(R.id.emptyTextView);
// Create a ListView-specific touch listener. ListViews are given special treatment because // Create a ListView-specific touch listener. ListViews are given special treatment because
// by default they handle touches for their list items... i.e. they're in charge of drawing // by default they handle touches for their list items... i.e. they're in charge of drawing
@ -839,6 +842,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)); listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} else { } else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)); listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
listEmptyTextView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} }
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION) { && visibleType != DashboardType.MAP_MARKERS_SELECTION) {
@ -853,6 +857,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light)); listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else { } else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light)); listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
listEmptyTextView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} }
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION) { && visibleType != DashboardType.MAP_MARKERS_SELECTION) {
@ -863,6 +868,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
listView.setDivider(null); listView.setDivider(null);
} }
} }
AndroidUtils.setTextSecondaryColor(mapActivity, listEmptyTextView, nightMode);
/* /*
listView.setOverscrollFooter(new ColorDrawable( listView.setOverscrollFooter(new ColorDrawable(
nightMode ? mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark) nightMode ? mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)
@ -876,6 +882,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
private void updateListAdapter() { private void updateListAdapter() {
listEmptyTextView.setVisibility(View.GONE);
listView.setEmptyView(null);
ContextMenuAdapter cm = null; ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) { if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
@ -887,6 +895,15 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
setDynamicListItems(listView, listAdapter); setDynamicListItems(listView, listAdapter);
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
if (listAdapter.getObjects().size() == 0) {
listEmptyTextView.setText(mapActivity.getString(R.string.no_waypoints_found));
if (landscape) {
listView.setEmptyView(listEmptyTextView);
} else {
listEmptyTextView.setVisibility(View.VISIBLE);
}
}
} else if (DashboardType.MAP_MARKERS == visibleType || visibleType == DashboardType.MAP_MARKERS_SELECTION) { } else if (DashboardType.MAP_MARKERS == visibleType || visibleType == DashboardType.MAP_MARKERS_SELECTION) {
mapMarkerDialogHelper.setSelectionMode(visibleType == DashboardType.MAP_MARKERS_SELECTION); mapMarkerDialogHelper.setSelectionMode(visibleType == DashboardType.MAP_MARKERS_SELECTION);
@ -900,6 +917,15 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
showMarkersRouteOnMap(); showMarkersRouteOnMap();
} }
if (listAdapter.getObjects().size() == 0) {
listEmptyTextView.setText(mapActivity.getString(R.string.no_map_markers_found));
if (landscape) {
listView.setEmptyView(listEmptyTextView);
} else {
listEmptyTextView.setVisibility(View.VISIBLE);
}
}
} else { } else {
if (DashboardType.CONFIGURE_SCREEN == visibleType) { if (DashboardType.CONFIGURE_SCREEN == visibleType) {