Updated functionality of waypoints dialog
This commit is contained in:
parent
f7cb3b46a8
commit
faba5d32af
4 changed files with 81 additions and 38 deletions
32
OsmAnd/res/layout/drawer_list_radius.xml
Normal file
32
OsmAnd/res/layout/drawer_list_radius.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp">
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/ProgressBar"
|
||||
android:layout_marginLeft="4dp"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:text="@string/search_radius_proximity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TextView android:id="@+id/descr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/sherpafy_selection"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="8dp"/>
|
||||
</LinearLayout>
|
|
@ -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<String> itemNames = new ArrayList<String>();
|
||||
final ArrayList<OnContextMenuClick> listeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||
final ArrayList<OnContextMenuClick> checkListeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||
final ArrayList<OnContextMenuClick> itemListeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||
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){
|
||||
|
@ -97,6 +104,10 @@ public class ContextMenuAdapter {
|
|||
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() {
|
||||
|
@ -172,6 +185,11 @@ public class ContextMenuAdapter {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Item loading(int loading) {
|
||||
this.loading = loading;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item layout(int l) {
|
||||
this.layout = l;
|
||||
return this;
|
||||
|
@ -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){
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Reference in a new issue