[Quick search] added custom search button

This commit is contained in:
Alexey Kulish 2016-10-01 21:52:19 +03:00
parent 73f3637ad8
commit 96a7b69be1
9 changed files with 598 additions and 20 deletions

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:scaleType="centerInside"
android:tint="?attr/color_dialog_buttons"
android:src="@drawable/ic_action_search_dark"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="?attr/color_dialog_buttons"
android:textStyle="bold"
android:textSize="@dimen/default_sub_text_size"
android:textAllCaps="true"
android:text="@string/custom_search"/>
</LinearLayout>

View file

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/osmand_orange"
android:minHeight="@dimen/dashboard_map_toolbar"
android:theme="?attr/toolbar_theme"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="14dp"
android:layout_marginTop="14dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:text="@string/create_custom_poi"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size_large"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="true"/>
<LinearLayout
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dashboard_map_toolbar"
android:background="?attr/color_dialog_buttons"
android:visibility="gone"
tools:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/barTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/color_white"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:textSize="@dimen/default_desc_text_size"
tools:text="Selected: 3 categories"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/barButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAllCaps="true"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="@color/color_white"
android:textSize="@dimen/default_desc_text_size"
android:text="@string/shared_string_show"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,9 @@
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
-->
<string name="selected_categories">Selected categories</string>
<string name="create_custom_poi">Create custom POI</string>
<string name="custom_search">Custom search</string>
<string name="shared_string_filters">Filters</string>
<string name="apply_filters">Apply filters</string>
<string name="save_filter">Save filter</string>

View file

@ -541,6 +541,10 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
combineWithPoiFilter(f);
}
public int getAcceptedTypesCount() {
return acceptedTypes.size();
}
public Map<PoiCategory, LinkedHashSet<String>> getAcceptedTypes() {
return new LinkedHashMap<>(acceptedTypes);
}

View file

@ -0,0 +1,352 @@
package net.osmand.plus.search;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.SwitchCompat;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms;
import java.text.Collator;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class QuickSearchCustomPoiFragment extends DialogFragment {
public static final String TAG = "QuickSearchCustomPoiFragment";
private static final String QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY = "quick_search_custom_poi_filter_id_key";
private View view;
private ListView listView;
private CategoryListAdapter listAdapter;
private String filterId;
private PoiUIFilter filter;
private PoiFiltersHelper helper;
private View bottomBar;
private AppCompatTextView barTitle;
private AppCompatTextView barButton;
public QuickSearchCustomPoiFragment() {
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean isLightTheme = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication();
helper = app.getPoiFilters();
if (getArguments() != null) {
filterId = getArguments().getString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY);
} else if (savedInstanceState != null) {
filterId = savedInstanceState.getString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY);
}
if (filterId != null) {
filter = helper.getFilterById(filterId);
}
if (filter == null) {
filter = helper.getCustomPOIFilter();
filter.clearFilter();
}
view = inflater.inflate(R.layout.search_custom_poi, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark));
toolbar.setNavigationContentDescription(R.string.shared_string_close);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
listView = (ListView) view.findViewById(android.R.id.list);
listView.setBackgroundColor(getResources().getColor(
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
: R.color.ctx_menu_info_view_bg_dark));
View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
listView.addHeaderView(header, null, false);
View footer = inflater.inflate(R.layout.list_shadow_footer, listView, false);
listView.addFooterView(footer, null, false);
listAdapter = new CategoryListAdapter(app, app.getPoiTypes().getCategories(false));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
PoiCategory category = listAdapter.getItem(position - listView.getHeaderViewsCount());
showDialog(category);
}
});
bottomBar = view.findViewById(R.id.bottomBar);
barTitle = (AppCompatTextView) view.findViewById(R.id.barTitle);
barButton = (AppCompatTextView) view.findViewById(R.id.barButton);
bottomBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
((QuickSearchDialogFragment) getParentFragment()).showFilter(filterId);
}
});
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY, filterId);
}
private int getIconId(PoiCategory category) {
OsmandApplication app = getMyApplication();
String id = null;
if (category != null) {
if (RenderingIcons.containsBigIcon(category.getIconKeyName())) {
id = category.getIconKeyName();
}
}
if (id != null) {
return RenderingIcons.getBigIconResourceId(id);
} else {
return 0;
}
}
public static void showDialog(DialogFragment parentFragment, String filterId) {
Bundle bundle = new Bundle();
if (filterId != null) {
bundle.putString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY, filterId);
}
QuickSearchCustomPoiFragment fragment = new QuickSearchCustomPoiFragment();
fragment.setArguments(bundle);
fragment.show(parentFragment.getChildFragmentManager(), TAG);
}
private class CategoryListAdapter extends ArrayAdapter<PoiCategory> {
private OsmandApplication app;
CategoryListAdapter(OsmandApplication app, List<PoiCategory> items) {
super(app, R.layout.list_item_icon_and_menu, items);
this.app = app;
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = convertView;
if (row == null) {
row = inflater.inflate(R.layout.list_item_icon_and_menu, parent, false);
}
PoiCategory category = getItem(position);
if (category != null) {
AppCompatImageView iconView = (AppCompatImageView) row.findViewById(R.id.icon);
AppCompatImageView secondaryIconView = (AppCompatImageView) row.findViewById(R.id.secondary_icon);
AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title);
AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description);
SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item);
boolean categorySelected = filter.isTypeAccepted(category);
IconsCache ic = app.getIconsCache();
int iconId = getIconId(category);
if (iconId != 0) {
if (categorySelected) {
iconView.setImageDrawable(ic.getIcon(iconId, R.color.osmand_orange));
} else {
iconView.setImageDrawable(ic.getThemedIcon(iconId));
}
} else {
iconView.setImageDrawable(null);
}
secondaryIconView.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_additional_option));
check.setChecked(filter.isTypeAccepted(category));
String textString = category.getTranslation();
titleView.setText(textString);
Set<String> subtypes = filter.getAcceptedSubtypes(category);
if (categorySelected) {
if (subtypes == null) {
descView.setText(getString(R.string.shared_string_all));
} else {
StringBuilder sb = new StringBuilder();
for (String st : subtypes) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(app.getPoiTypes().getPoiTranslation(st));
}
descView.setText(sb.toString());
}
descView.setVisibility(View.VISIBLE);
} else {
descView.setVisibility(View.GONE);
}
row.findViewById(R.id.divider).setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE);
addRowListener(category, check);
}
return (row);
}
private void addRowListener(final PoiCategory category, final SwitchCompat check) {
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (check.isChecked()) {
filter.setTypeToAccept(category, true);
showDialog(category);
} else {
filter.setTypeToAccept(category, false);
saveFilter();
}
notifyDataSetChanged();
}
});
}
}
private void saveFilter() {
helper.editPoiFilter(filter);
if (filter.isEmpty()) {
bottomBar.setVisibility(View.GONE);
} else {
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount());
bottomBar.setVisibility(View.VISIBLE);
}
}
private void showDialog(final PoiCategory poiCategory) {
final int index = listView.getFirstVisiblePosition();
View v = listView.getChildAt(0);
final int top = (v == null) ? 0 : v.getTop();
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
final LinkedHashMap<String, String> subCategories = new LinkedHashMap<String, String>();
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
if (acceptedCategories != null) {
for(String s : acceptedCategories) {
subCategories.put(s, Algorithms.capitalizeFirstLetterAndLowercase(s));
}
}
for(PoiType pt : poiCategory.getPoiTypes()) {
subCategories.put(pt.getKeyName(), pt.getTranslation());
}
final String[] array = subCategories.keySet().toArray(new String[0]);
final Collator cl = Collator.getInstance();
cl.setStrength(Collator.SECONDARY);
Arrays.sort(array, 0, array.length, new Comparator<String>() {
@Override
public int compare(String object1, String object2) {
String v1 = subCategories.get(object1);
String v2 = subCategories.get(object2);
return cl.compare(v1, v2);
}
});
final String[] visibleNames = new String[array.length];
final boolean[] selected = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
final String subcategory = array[i];
visibleNames[i] = subCategories.get(subcategory);
if (acceptedCategories == null) {
selected[i] = true;
} else {
selected[i] = acceptedCategories.contains(subcategory);
}
}
builder.setTitle(poiCategory.getTranslation());
builder.setCancelable(true);
builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setPositiveButton(getContext().getText(R.string.shared_string_apply), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
LinkedHashSet<String> accepted = new LinkedHashSet<String>();
for (int i = 0; i < selected.length; i++) {
if(selected[i]){
accepted.add(array[i]);
}
}
if (subCategories.size() == accepted.size()) {
filter.selectSubTypesToAccept(poiCategory, null);
} else if(accepted.size() == 0){
filter.setTypeToAccept(poiCategory, false);
} else {
filter.selectSubTypesToAccept(poiCategory, accepted);
}
saveFilter();
listAdapter.notifyDataSetChanged();
listView.setSelectionFromTop(index, top);
}
});
/*
builder.setPositiveButton(getContext().getText(R.string.shared_string_select_all), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selectAllFromCategory(poiCategory);
listView.setSelectionFromTop(index, top);
}
});
*/
builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
selected[item] = isChecked;
}
});
builder.show();
}
public void selectAllFromCategory(PoiCategory poiCategory) {
filter.updateTypesToAccept(poiCategory);
saveFilter();
listAdapter.notifyDataSetChanged();
}
}

View file

@ -5,6 +5,7 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
@ -62,6 +63,7 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControll
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchPhrase;
@ -845,6 +847,15 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr));
}
rows.add(new CustomSearchButton(app, new OnClickListener() {
@Override
public void onClick(View v) {
PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter();
filter.clearFilter();
QuickSearchCustomPoiFragment.showDialog(
QuickSearchDialogFragment.this, filter.getFilterId());
}
}));
categoriesSearchFragment.updateListAdapter(rows, false);
}
} catch (IOException e) {
@ -1286,6 +1297,28 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
}
public void showFilter(String filterId) {
PoiUIFilter filter = app.getPoiFilters().getFilterById(filterId);
SearchResult sr = new SearchResult(searchUICore.getPhrase());
sr.localeName = filter.getName();
sr.object = filter;
sr.priority = 0;
sr.objectType = ObjectType.POI_TYPE;
searchUICore.selectSearchResult(sr);
String txt = filter.getName() + " ";
searchQuery = txt;
searchEditText.setText(txt);
searchEditText.setSelection(txt.length());
updateToolbarButton();
SearchSettings settings = searchUICore.getPhrase().getSettings();
if (settings.getRadiusLevel() != 1) {
searchUICore.updateSettings(settings.setRadiusLevel(1));
}
runCoreSearch(txt, false, false);
}
public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
private final String[] fragments = new String[]{QuickSearchHistoryListFragment.class.getName(),
QuickSearchCategoriesListFragment.class.getName()};
@ -1397,4 +1430,28 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
super(TopToolbarControllerType.QUICK_SEARCH);
}
}
public static class CustomSearchButton extends QuickSearchListItem {
private OnClickListener onClickListener;
public CustomSearchButton(OsmandApplication app, OnClickListener onClickListener) {
super(app, null);
this.onClickListener = onClickListener;
}
@Override
public Drawable getIcon() {
return app.getIconsCache().getIcon(R.drawable.ic_action_search_dark);
}
@Override
public String getName() {
return app.getString(R.string.custom_search);
}
public OnClickListener getOnClickListener() {
return onClickListener;
}
}
}

View file

@ -18,6 +18,7 @@ import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.CustomSearchButton;
import net.osmand.search.core.SearchPhrase;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser;
@ -37,6 +38,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
private int searchMoreItemPosition;
private int selectAllItemPosition;
private int customSearchItemPosition;
private int screenOrientation;
private int dp56;
@ -50,6 +52,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
private static final int ITEM_TYPE_REGULAR = 0;
private static final int ITEM_TYPE_SEARCH_MORE = 1;
private static final int ITEM_TYPE_SELECT_ALL = 2;
private static final int ITEM_TYPE_CUSTOM_SEARCH = 3;
public interface OnSelectionListener {
@ -166,11 +169,13 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
private void acquireAdditionalItemsPositions() {
selectAllItemPosition = -1;
searchMoreItemPosition = -1;
customSearchItemPosition = -1;
if (getCount() > 0) {
QuickSearchListItem first = getItem(0);
QuickSearchListItem last = getItem(getCount() - 1);
selectAllItemPosition = first instanceof QuickSearchSelectAllListItem ? 0 : -1;
searchMoreItemPosition = last instanceof QuickSearchMoreListItem ? getCount() - 1 : -1;
customSearchItemPosition = last instanceof CustomSearchButton ? getCount() - 1 : -1;
}
}
@ -183,6 +188,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
public int getItemViewType(int position) {
if (position == searchMoreItemPosition) {
return ITEM_TYPE_SEARCH_MORE;
} else if (position == customSearchItemPosition) {
return ITEM_TYPE_CUSTOM_SEARCH;
} else if (position == selectAllItemPosition) {
return ITEM_TYPE_SELECT_ALL;
} else {
@ -192,7 +199,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
@Override
public int getViewTypeCount() {
return 3;
return 4;
}
@Override
@ -211,6 +218,15 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
} else if (viewType == ITEM_TYPE_CUSTOM_SEARCH) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_custom_list_item, null);
} else {
view = (LinearLayout) convertView;
}
} else if (viewType == ITEM_TYPE_SELECT_ALL) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app

View file

@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.search.QuickSearchDialogFragment.CustomSearchButton;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
@ -81,22 +82,26 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
@Override
public void onListItemClick(ListView l, View view, int position, long id) {
QuickSearchListItem item = listAdapter.getItem(position - l.getHeaderViewsCount());
if (item instanceof QuickSearchMoreListItem) {
((QuickSearchMoreListItem) item).getOnClickListener().onClick(view);
} else {
SearchResult sr = item.getSearchResult();
if (sr.objectType == ObjectType.POI
|| sr.objectType == ObjectType.LOCATION
|| sr.objectType == ObjectType.HOUSE
|| sr.objectType == ObjectType.FAVORITE
|| sr.objectType == ObjectType.RECENT_OBJ
|| sr.objectType == ObjectType.WPT
|| sr.objectType == ObjectType.STREET_INTERSECTION) {
showOnMap(sr);
if (item != null) {
if (item instanceof QuickSearchMoreListItem) {
((QuickSearchMoreListItem) item).getOnClickListener().onClick(view);
} else if (item instanceof CustomSearchButton) {
((CustomSearchButton) item).getOnClickListener().onClick(view);
} else {
dialogFragment.completeQueryWithObject(item.getSearchResult());
SearchResult sr = item.getSearchResult();
if (sr.objectType == ObjectType.POI
|| sr.objectType == ObjectType.LOCATION
|| sr.objectType == ObjectType.HOUSE
|| sr.objectType == ObjectType.FAVORITE
|| sr.objectType == ObjectType.RECENT_OBJ
|| sr.objectType == ObjectType.WPT
|| sr.objectType == ObjectType.STREET_INTERSECTION) {
showOnMap(sr);
} else {
dialogFragment.completeQueryWithObject(item.getSearchResult());
}
}
}
}

View file

@ -216,10 +216,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
editTextView.findViewById(R.id.checkboxItem).setVisibility(View.GONE);
listView.addHeaderView(editTextView);
View bottomShadowView = inflater.inflate(R.layout.card_bottom_divider, listView, false);
bottomShadowView.setMinimumHeight(AndroidUtils.dpToPx(getContext(), 16f));
listView.addFooterView(bottomShadowView);
adapter = new PoiFilterListAdapter(getMyApplication(), getListItems());
View bottomShadowView = inflater.inflate(R.layout.list_shadow_footer, listView, false);
listView.addFooterView(bottomShadowView, null, false);
adapter = new PoiFilterListAdapter(app, getListItems());
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override