diff --git a/OsmAnd/res/layout/drawer_list_radius.xml b/OsmAnd/res/layout/drawer_list_radius.xml new file mode 100644 index 0000000000..92c19f8362 --- /dev/null +++ b/OsmAnd/res/layout/drawer_list_radius.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index e462bb6719..b4041e51c2 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -19,7 +19,8 @@ public class ContextMenuAdapter { items.clear(); isCategory.clear(); itemNames.clear(); - listeners.clear(); + checkListeners.clear(); + itemListeners.clear(); selectedList.clear(); layoutIds.clear(); iconList.clear(); @@ -40,8 +41,10 @@ public class ContextMenuAdapter { final TIntArrayList items = new TIntArrayList(); final TIntArrayList isCategory = new TIntArrayList(); final ArrayList itemNames = new ArrayList(); - final ArrayList listeners = new ArrayList(); + final ArrayList checkListeners = new ArrayList(); + final ArrayList itemListeners = new ArrayList(); final TIntArrayList selectedList = new TIntArrayList(); + final TIntArrayList loadingList = new TIntArrayList(); final TIntArrayList layoutIds = new TIntArrayList(); final TIntArrayList iconList = new TIntArrayList(); final TIntArrayList iconListLight = new TIntArrayList(); @@ -68,7 +71,11 @@ public class ContextMenuAdapter { } public OnContextMenuClick getClickAdapter(int i) { - return listeners.get(i); + return checkListeners.get(i); + } + + public OnContextMenuClick getItemClickAdapter(int i) { + return itemListeners.get(i); } public String getItemName(int pos){ @@ -96,6 +103,10 @@ public class ContextMenuAdapter { public int getSelection(int pos) { return selectedList.get(pos); } + + public int getLoading(int pos) { + return loadingList.get(pos); + } public void setSelection(int pos, int s) { selectedList.set(pos, s); @@ -142,10 +153,12 @@ public class ContextMenuAdapter { String name; int selected = -1; int layout = -1; + int loading = -1; boolean cat; int pos = -1; String description = ""; - private OnContextMenuClick listener; + private OnContextMenuClick checkBoxListener; + private OnContextMenuClick itemClickListener; boolean enabled = false; private Item() { @@ -171,6 +184,11 @@ public class ContextMenuAdapter { this.selected = selected; return this; } + + public Item loading(int loading) { + this.loading = loading; + return this; + } public Item layout(int l) { this.layout = l; @@ -183,9 +201,13 @@ public class ContextMenuAdapter { } public Item listen(OnContextMenuClick l) { - this.listener = l; + this.checkBoxListener = l; return this; + } + public Item itemClickListen(OnContextMenuClick l) { + this.itemClickListener = l; + return this; } public void reg() { @@ -196,10 +218,11 @@ public class ContextMenuAdapter { itemNames.add(pos, name); itemDescription.add(pos, description); selectedList.insert(pos, selected); + loadingList.insert(pos, loading); layoutIds.insert(pos, layout); iconList.insert(pos, icon); iconListLight.insert(pos, lightIcon); - listeners.add(pos, listener); + checkListeners.add(pos, checkBoxListener); isCategory.insert(pos, cat ? 1 : 0); } @@ -222,11 +245,13 @@ public class ContextMenuAdapter { items.removeAt(pos); itemNames.remove(pos); selectedList.removeAt(pos); + loadingList.clear(); iconList.removeAt(pos); iconListLight.removeAt(pos); - listeners.remove(pos); + checkListeners.remove(pos); isCategory.removeAt(pos); layoutIds.removeAt(pos); + loadingList.clear(); } public int getLayoutId(int position) { @@ -270,30 +295,8 @@ public class ContextMenuAdapter { tv.setTypeface(null); } - if (v.findViewById(R.id.check_item) instanceof CheckBox){ - final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item)); - - if(selectedList.get(position) != -1) { - ch.setOnCheckedChangeListener(null); - ch.setVisibility(View.VISIBLE); - ch.setChecked(selectedList.get(position) > 0); - ch.setOnCheckedChangeListener(new OnCheckedChangeListener() { - - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - OnContextMenuClick ca = getClickAdapter(position); - if(ca != null) { - ca.onContextMenuClick(getElementId(position), position, isChecked); - } - } - }); - ch.setVisibility(View.VISIBLE); - } else if (ch != null) { - ch.setVisibility(View.GONE); - } - } else if (v.findViewById(R.id.check_item) instanceof Switch) { - final Switch ch = (Switch) v.findViewById(R.id.check_item); - + if (v.findViewById(R.id.check_item) != null) { + CompoundButton ch = (CompoundButton) v.findViewById(R.id.check_item); if(selectedList.get(position) != -1) { ch.setOnCheckedChangeListener(null); ch.setVisibility(View.VISIBLE); @@ -314,6 +317,14 @@ public class ContextMenuAdapter { } } + if (v.findViewById(R.id.ProgressBar) != null){ + ProgressBar bar = (ProgressBar) v.findViewById(R.id.ProgressBar); + if(loadingList.get(position) == 1){ + bar.setVisibility(View.VISIBLE); + } else { + bar.setVisibility(View.INVISIBLE); + } + } String itemDescr = getItemDescr(position); if (v.findViewById(R.id.descr) != null){ diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 17d079d851..85ccc9cf21 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -564,7 +564,7 @@ public class OsmAndLocationProvider implements SensorEventListener { return false; } - // Working with location listeners + // Working with location checkListeners private class NetworkListener implements LocationListener { @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 511ea1ec78..0596c6e968 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -542,7 +542,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { if (waypointHelper.isTypeVisible(i)) { final boolean checked = waypointHelper.isTypeEnabled(i); final int type = i; - adapter.item(getHeader(ctx, i, checked)).enabled(checked).layout(R.layout.drawer_list_poi_header).listen(new ContextMenuAdapter.OnContextMenuClick() { + adapter.item(getHeader(ctx, i, checked)).enabled(checked).layout(R.layout.drawer_list_poi_header).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() { @Override public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) { running[0] = pos; @@ -554,10 +554,10 @@ public class WaypointDialogHelper implements OsmAndLocationListener { } return false; } - }).reg(); + }).loading(0).reg(); if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){ - adapter.item(ctx.getString(R.string.search_radius_proximity)).listen(new ContextMenuAdapter.OnContextMenuClick() { + adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() { @Override public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) { int length = WaypointHelper.SEARCH_RADIUS_VALUES.length; @@ -588,9 +588,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener { .show(); return false; } - }).reg(); + }).loading(0).selected(app.getSettings().SHOW_POI_OVER_MAP.get() ? 1 : 0).reg(); } else if (i == WaypointHelper.FAVORITES && waypointHelper.isTypeEnabled(WaypointHelper.FAVORITES)){ - adapter.item(ctx.getString(R.string.search_radius_proximity)).listen(new ContextMenuAdapter.OnContextMenuClick() { + adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() { @Override public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) { int length = WaypointHelper.SEARCH_RADIUS_VALUES.length; @@ -620,7 +620,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { .show(); return false; } - }).reg(); + }).loading(0).selected(app.getSettings().SHOW_FAVORITES.get() ? 1 : 0).reg(); } if (tp != null && tp.size() > 0) { for (LocationPointWrapper p : tp){