Fixed multiselection bugs.
This commit is contained in:
parent
174e4ecc4b
commit
9fcab7cbe2
1 changed files with 16 additions and 9 deletions
|
@ -266,13 +266,13 @@ public class MapActivityLayers {
|
||||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
final List<PoiUIFilter> list = new ArrayList<>();
|
final List<PoiUIFilter> list = new ArrayList<>();
|
||||||
list.add(poiFilters.getCustomPOIFilter());
|
|
||||||
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||||
addFilterToList(adapter, list, f, true);
|
addFilterToList(adapter, list, f, true);
|
||||||
}
|
}
|
||||||
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
|
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
|
||||||
addFilterToList(adapter, list, f, true);
|
addFilterToList(adapter, list, f, true);
|
||||||
}
|
}
|
||||||
|
list.add(poiFilters.getCustomPOIFilter());
|
||||||
|
|
||||||
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
@ -294,6 +294,15 @@ public class MapActivityLayers {
|
||||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
for (int i = 0; i < listAdapter.getCount(); i++) {
|
||||||
|
ContextMenuItem item = listAdapter.getItem(i);
|
||||||
|
PoiUIFilter filter = list.get(i);
|
||||||
|
if (item.getSelected()) {
|
||||||
|
getApplication().getPoiFilters().addSelectedPoiFilter(filter);
|
||||||
|
} else {
|
||||||
|
getApplication().getPoiFilters().removeSelectedPoiFilter(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -393,18 +402,16 @@ public class MapActivityLayers {
|
||||||
list.add(f);
|
list.add(f);
|
||||||
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder();
|
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder();
|
||||||
if (multichoice) {
|
if (multichoice) {
|
||||||
|
builder.setSelected(getApplication().getPoiFilters().isPoiFilterSelected(f));
|
||||||
builder.setListener(new ContextMenuAdapter.ItemClickListener() {
|
builder.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter,
|
||||||
if (isChecked) {
|
int itemId, int position, boolean isChecked) {
|
||||||
getApplication().getPoiFilters().addSelectedPoiFilter(f);
|
ContextMenuItem item = adapter.getItem(position);
|
||||||
} else {
|
item.setSelected(isChecked);
|
||||||
getApplication().getPoiFilters().removeSelectedPoiFilter(f);
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setSelected(getApplication().getPoiFilters().isPoiFilterSelected(f));
|
|
||||||
}
|
}
|
||||||
builder.setTitle(f.getName());
|
builder.setTitle(f.getName());
|
||||||
if (RenderingIcons.containsBigIcon(f.getIconId())) {
|
if (RenderingIcons.containsBigIcon(f.getIconId())) {
|
||||||
|
|
Loading…
Reference in a new issue