Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
02c5eb6009
7 changed files with 152 additions and 74 deletions
|
@ -9,6 +9,7 @@
|
||||||
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="type_address">Type address</string>
|
||||||
<string name="type_city_town">Type city or town</string>
|
<string name="type_city_town">Type city or town</string>
|
||||||
<string name="type_postcode">Type postcode</string>
|
<string name="type_postcode">Type postcode</string>
|
||||||
<string name="nearest_cities">Nearest cities</string>
|
<string name="nearest_cities">Nearest cities</string>
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private QuickSearchMainListFragment mainSearchFragment;
|
private QuickSearchMainListFragment mainSearchFragment;
|
||||||
private QuickSearchHistoryListFragment historySearchFragment;
|
private QuickSearchHistoryListFragment historySearchFragment;
|
||||||
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
||||||
private QuickSearchAddressListFragment addrSearchFragment;
|
private QuickSearchAddressListFragment addressSearchFragment;
|
||||||
private QuickSearchToolbarController toolbarController;
|
private QuickSearchToolbarController toolbarController;
|
||||||
|
|
||||||
private Toolbar toolbarEdit;
|
private Toolbar toolbarEdit;
|
||||||
|
@ -436,7 +436,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
addressSearch = position == 2;
|
addressSearch = position == 2;
|
||||||
updateClearButtonAndHint();
|
updateClearButtonAndHint();
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
startSearchingCity(true, true);
|
startAddressSearch();
|
||||||
} else {
|
} else {
|
||||||
stopAddressSearch();
|
stopAddressSearch();
|
||||||
}
|
}
|
||||||
|
@ -466,6 +466,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
updateClearButtonVisibility(true);
|
updateClearButtonVisibility(true);
|
||||||
boolean textEmpty = newQueryText.length() == 0;
|
boolean textEmpty = newQueryText.length() == 0;
|
||||||
updateTabbarVisibility(textEmpty);
|
updateTabbarVisibility(textEmpty);
|
||||||
|
if (textEmpty && addressSearch) {
|
||||||
|
startAddressSearch();
|
||||||
|
}
|
||||||
if (textEmpty && poiFilterApplied) {
|
if (textEmpty && poiFilterApplied) {
|
||||||
poiFilterApplied = false;
|
poiFilterApplied = false;
|
||||||
reloadCategories();
|
reloadCategories();
|
||||||
|
@ -477,15 +480,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
||||||
searchQuery = newQueryText;
|
searchQuery = newQueryText;
|
||||||
if (Algorithms.isEmpty(searchQuery)) {
|
if (Algorithms.isEmpty(searchQuery)) {
|
||||||
if (addressSearch) {
|
|
||||||
startSearchingCity(true, true);
|
|
||||||
}
|
|
||||||
searchUICore.resetPhrase();
|
searchUICore.resetPhrase();
|
||||||
} else {
|
} else {
|
||||||
if (addressSearch) {
|
|
||||||
updateAddressSearch(searchUICore.getPhrase().getLastSelectedWord() != null
|
|
||||||
? searchUICore.getPhrase().getLastSelectedWord().getResult() : null);
|
|
||||||
}
|
|
||||||
runSearch();
|
runSearch();
|
||||||
}
|
}
|
||||||
} else if (runSearchFirstTime) {
|
} else if (runSearchFirstTime) {
|
||||||
|
@ -517,6 +513,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
searchUICore.updateSettings(ss);
|
searchUICore.updateSettings(ss);
|
||||||
updateClearButtonAndHint();
|
updateClearButtonAndHint();
|
||||||
updateClearButtonVisibility(true);
|
updateClearButtonVisibility(true);
|
||||||
|
if (addressSearchFragment != null) {
|
||||||
|
reloadCities();
|
||||||
|
}
|
||||||
startLocationUpdate();
|
startLocationUpdate();
|
||||||
}
|
}
|
||||||
updateToolbarButton();
|
updateToolbarButton();
|
||||||
|
@ -898,7 +897,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
clearButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_get_my_location, R.color.color_myloc_distance));
|
clearButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_get_my_location, R.color.color_myloc_distance));
|
||||||
} else {
|
} else {
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
searchEditText.setHint(R.string.type_city_town);
|
searchEditText.setHint(R.string.type_address);
|
||||||
} else {
|
} else {
|
||||||
searchEditText.setHint(R.string.search_poi_category_hint);
|
searchEditText.setHint(R.string.search_poi_category_hint);
|
||||||
}
|
}
|
||||||
|
@ -953,7 +952,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDRESS:
|
case ADDRESS:
|
||||||
addrSearchFragment = (QuickSearchAddressListFragment) searchListFragment;
|
addressSearchFragment = (QuickSearchAddressListFragment) searchListFragment;
|
||||||
reloadCities();
|
reloadCities();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1002,8 +1001,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
private void reloadCategoriesInternal() {
|
private void reloadCategoriesInternal() {
|
||||||
try {
|
try {
|
||||||
SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class,
|
if (addressSearch) {
|
||||||
"", null);
|
stopAddressSearch();
|
||||||
|
}
|
||||||
|
SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class, "", null);
|
||||||
|
if (addressSearch) {
|
||||||
|
startAddressSearch();
|
||||||
|
}
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||||
|
@ -1052,11 +1056,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
private void reloadCitiesInternal() {
|
private void reloadCitiesInternal() {
|
||||||
try {
|
try {
|
||||||
startSearchingCity(false, false);
|
startNearestCitySearch();
|
||||||
SearchResultCollection res = searchUICore.shallowSearch(SearchAddressByNameAPI.class,
|
SearchResultCollection res = searchUICore.shallowSearch(SearchAddressByNameAPI.class, "", null);
|
||||||
"", null);
|
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
startSearchingCity(true, true);
|
startAddressSearch();
|
||||||
} else {
|
} else {
|
||||||
stopAddressSearch();
|
stopAddressSearch();
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1070,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
searchEditText.setHint(R.string.type_city_town);
|
searchEditText.setHint(R.string.type_city_town);
|
||||||
startSearchingCity(true, true);
|
startCitySearch();
|
||||||
updateTabbarVisibility(false);
|
updateTabbarVisibility(false);
|
||||||
runSearch();
|
runSearch();
|
||||||
searchEditText.requestFocus();
|
searchEditText.requestFocus();
|
||||||
|
@ -1079,7 +1082,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
searchEditText.setHint(R.string.type_postcode);
|
searchEditText.setHint(R.string.type_postcode);
|
||||||
startSearchingPostcode(true);
|
startPostcodeSearch();
|
||||||
mainSearchFragment.getAdapter().clear();
|
mainSearchFragment.getAdapter().clear();
|
||||||
updateTabbarVisibility(false);
|
updateTabbarVisibility(false);
|
||||||
searchEditText.requestFocus();
|
searchEditText.requestFocus();
|
||||||
|
@ -1097,7 +1100,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
limit--;
|
limit--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addrSearchFragment.updateListAdapter(rows, false);
|
addressSearchFragment.updateListAdapter(rows, false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
app.showToastMessage(e.getMessage());
|
app.showToastMessage(e.getMessage());
|
||||||
|
@ -1129,8 +1132,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
private void reloadHistoryInternal() {
|
private void reloadHistoryInternal() {
|
||||||
try {
|
try {
|
||||||
SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class,
|
if (addressSearch) {
|
||||||
"", null);
|
stopAddressSearch();
|
||||||
|
}
|
||||||
|
SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class, "", null);
|
||||||
|
if (addressSearch) {
|
||||||
|
startAddressSearch();
|
||||||
|
}
|
||||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||||
|
@ -1144,56 +1152,50 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startSearchingCity(boolean sortByName, boolean searchVillages) {
|
private void startAddressSearch() {
|
||||||
SearchSettings settings = searchUICore.getSearchSettings()
|
SearchSettings settings = searchUICore.getSearchSettings()
|
||||||
.setEmptyQueryAllowed(true)
|
.setEmptyQueryAllowed(true)
|
||||||
.setAddressSearch(true)
|
.setAddressSearch(true)
|
||||||
|
.setSortByName(true)
|
||||||
|
.setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE, ObjectType.POSTCODE,
|
||||||
|
ObjectType.HOUSE, ObjectType.STREET_INTERSECTION, ObjectType.STREET,
|
||||||
|
ObjectType.LOCATION, ObjectType.PARTIAL_LOCATION)
|
||||||
.setRadiusLevel(1);
|
.setRadiusLevel(1);
|
||||||
|
|
||||||
if (sortByName) {
|
|
||||||
settings = settings.setSortByName(true);
|
|
||||||
}
|
|
||||||
if (searchVillages) {
|
|
||||||
settings = settings.setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE);
|
|
||||||
} else {
|
|
||||||
settings = settings.setSearchTypes(ObjectType.CITY);
|
|
||||||
}
|
|
||||||
searchUICore.updateSettings(settings);
|
searchUICore.updateSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startSearchingPostcode(boolean sortByName) {
|
private void startCitySearch() {
|
||||||
|
SearchSettings settings = searchUICore.getSearchSettings()
|
||||||
|
.setEmptyQueryAllowed(true)
|
||||||
|
.setAddressSearch(true)
|
||||||
|
.setSortByName(true)
|
||||||
|
.setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE)
|
||||||
|
.setRadiusLevel(1);
|
||||||
|
|
||||||
|
searchUICore.updateSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startNearestCitySearch() {
|
||||||
|
SearchSettings settings = searchUICore.getSearchSettings()
|
||||||
|
.setEmptyQueryAllowed(true)
|
||||||
|
.setAddressSearch(true)
|
||||||
|
.setSortByName(false)
|
||||||
|
.setSearchTypes(ObjectType.CITY)
|
||||||
|
.setRadiusLevel(1);
|
||||||
|
|
||||||
|
searchUICore.updateSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startPostcodeSearch() {
|
||||||
SearchSettings settings = searchUICore.getSearchSettings()
|
SearchSettings settings = searchUICore.getSearchSettings()
|
||||||
.setSearchTypes(ObjectType.POSTCODE)
|
.setSearchTypes(ObjectType.POSTCODE)
|
||||||
.setEmptyQueryAllowed(false)
|
.setEmptyQueryAllowed(false)
|
||||||
.setAddressSearch(true)
|
.setAddressSearch(true)
|
||||||
.setRadiusLevel(1);
|
.setSortByName(true)
|
||||||
|
|
||||||
if (sortByName) {
|
|
||||||
settings = settings.setSortByName(true);
|
|
||||||
}
|
|
||||||
searchUICore.updateSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAddressSearch(SearchResult searchResult) {
|
|
||||||
if (searchResult != null) {
|
|
||||||
if (searchResult.objectType == ObjectType.STREET) {
|
|
||||||
SearchSettings settings = searchUICore.getSearchSettings()
|
|
||||||
.setSearchTypes(ObjectType.HOUSE, ObjectType.STREET_INTERSECTION)
|
|
||||||
.setEmptyQueryAllowed(false)
|
|
||||||
.setSortByName(false)
|
|
||||||
.setRadiusLevel(1);
|
.setRadiusLevel(1);
|
||||||
|
|
||||||
searchUICore.updateSettings(settings);
|
searchUICore.updateSettings(settings);
|
||||||
} else if (searchResult.objectType == ObjectType.CITY || searchResult.objectType == ObjectType.VILLAGE) {
|
|
||||||
SearchSettings settings = searchUICore.getSearchSettings()
|
|
||||||
.setSearchTypes(ObjectType.STREET)
|
|
||||||
.setEmptyQueryAllowed(false)
|
|
||||||
.setSortByName(false)
|
|
||||||
.setRadiusLevel(1);
|
|
||||||
|
|
||||||
searchUICore.updateSettings(settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopAddressSearch() {
|
private void stopAddressSearch() {
|
||||||
|
@ -1384,9 +1386,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchUICore.selectSearchResult(sr);
|
searchUICore.selectSearchResult(sr);
|
||||||
if (addressSearch) {
|
|
||||||
updateAddressSearch(sr);
|
|
||||||
}
|
|
||||||
String txt = searchUICore.getPhrase().getText(true);
|
String txt = searchUICore.getPhrase().getText(true);
|
||||||
searchQuery = txt;
|
searchQuery = txt;
|
||||||
searchEditText.setText(txt);
|
searchEditText.setText(txt);
|
||||||
|
@ -1573,8 +1572,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
historySearchFragment.updateLocation(latLon, heading);
|
historySearchFragment.updateLocation(latLon, heading);
|
||||||
} else if (categoriesSearchFragment != null && viewPager.getCurrentItem() == 1) {
|
} else if (categoriesSearchFragment != null && viewPager.getCurrentItem() == 1) {
|
||||||
categoriesSearchFragment.updateLocation(latLon, heading);
|
categoriesSearchFragment.updateLocation(latLon, heading);
|
||||||
} else if (addrSearchFragment != null && viewPager.getCurrentItem() == 2) {
|
} else if (addressSearchFragment != null && viewPager.getCurrentItem() == 2) {
|
||||||
addrSearchFragment.updateLocation(latLon, heading);
|
addressSearchFragment.updateLocation(latLon, heading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1590,8 +1589,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
if (categoriesSearchFragment != null) {
|
if (categoriesSearchFragment != null) {
|
||||||
categoriesSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
|
categoriesSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
|
||||||
}
|
}
|
||||||
if (addrSearchFragment != null) {
|
if (addressSearchFragment != null) {
|
||||||
addrSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
|
addressSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,9 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertListItem(@NonNull QuickSearchListItem item, int index) {
|
public void insertListItem(@NonNull QuickSearchListItem item, int index) {
|
||||||
|
if (hasSearchMoreItem && item.getType() == QuickSearchListItemType.SEARCH_MORE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setNotifyOnChange(false);
|
setNotifyOnChange(false);
|
||||||
insert(item, index);
|
insert(item, index);
|
||||||
if (item.getType() == QuickSearchListItemType.SEARCH_MORE) {
|
if (item.getType() == QuickSearchListItemType.SEARCH_MORE) {
|
||||||
|
@ -185,7 +188,10 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(int position) {
|
public boolean isEnabled(int position) {
|
||||||
return getItem(position).getType() != QuickSearchListItemType.HEADER;
|
QuickSearchListItemType type = getItem(position).getType();
|
||||||
|
return type != QuickSearchListItemType.HEADER
|
||||||
|
&& type != QuickSearchListItemType.TOP_SHADOW
|
||||||
|
&& type != QuickSearchListItemType.BOTTOM_SHADOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,6 +263,26 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
view.findViewById(R.id.top_divider)
|
view.findViewById(R.id.top_divider)
|
||||||
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
|
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
|
||||||
|
if (convertView == null) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
view = (LinearLayout) inflater.inflate(
|
||||||
|
R.layout.list_shadow_header, null);
|
||||||
|
} else {
|
||||||
|
view = (LinearLayout) convertView;
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||||
|
if (convertView == null) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
view = (LinearLayout) inflater.inflate(
|
||||||
|
R.layout.list_shadow_footer, null);
|
||||||
|
} else {
|
||||||
|
view = (LinearLayout) convertView;
|
||||||
|
}
|
||||||
|
return view;
|
||||||
} else {
|
} else {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
@ -344,7 +370,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
app.getSettings().isLightContent() ? R.color.bg_color_light : R.color.bg_color_dark));
|
app.getSettings().isLightContent() ? R.color.bg_color_light : R.color.bg_color_dark));
|
||||||
View divider = view.findViewById(R.id.divider);
|
View divider = view.findViewById(R.id.divider);
|
||||||
if (divider != null) {
|
if (divider != null) {
|
||||||
if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER) {
|
if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER
|
||||||
|
|| getItem(position + 1).getType() == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||||
divider.setVisibility(View.GONE);
|
divider.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
divider.setVisibility(View.VISIBLE);
|
divider.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -29,15 +29,18 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.OsmAndListFragment;
|
import net.osmand.plus.base.OsmAndListFragment;
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
|
import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||||
|
import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
|
||||||
import net.osmand.search.core.ObjectType;
|
import net.osmand.search.core.ObjectType;
|
||||||
import net.osmand.search.core.SearchResult;
|
import net.osmand.search.core.SearchResult;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
@ -77,10 +80,10 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
|
//View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
|
||||||
View footer = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_footer, null);
|
//View footer = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_footer, null);
|
||||||
listView.addHeaderView(header, null, false);
|
//listView.addHeaderView(header, null, false);
|
||||||
listView.addFooterView(footer, null, false);
|
//listView.addFooterView(footer, null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +325,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
public void updateListAdapter(List<QuickSearchListItem> listItems, boolean append) {
|
public void updateListAdapter(List<QuickSearchListItem> listItems, boolean append) {
|
||||||
if (listAdapter != null) {
|
if (listAdapter != null) {
|
||||||
listAdapter.setListItems(listItems);
|
List<QuickSearchListItem> list = new ArrayList<>(listItems);
|
||||||
|
if (list.size() > 0) {
|
||||||
|
list.add(0, new QuickSearchTopShadowListItem(getMyApplication()));
|
||||||
|
list.add(new QuickSearchBottomShadowListItem(getMyApplication()));
|
||||||
|
}
|
||||||
|
listAdapter.setListItems(list);
|
||||||
if (!append) {
|
if (!append) {
|
||||||
getListView().setSelection(0);
|
getListView().setSelection(0);
|
||||||
}
|
}
|
||||||
|
@ -331,7 +339,20 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
public void addListItem(QuickSearchListItem listItem) {
|
public void addListItem(QuickSearchListItem listItem) {
|
||||||
if (listItem != null) {
|
if (listItem != null) {
|
||||||
|
if (listAdapter.getCount() == 0) {
|
||||||
|
List<QuickSearchListItem> list = new ArrayList<>();
|
||||||
|
list.add(new QuickSearchTopShadowListItem(getMyApplication()));
|
||||||
|
list.add(listItem);
|
||||||
|
list.add(new QuickSearchBottomShadowListItem(getMyApplication()));
|
||||||
|
listAdapter.setListItems(list);
|
||||||
|
} else {
|
||||||
|
QuickSearchListItem lastItem = listAdapter.getItem(listAdapter.getCount() - 1);
|
||||||
|
if (lastItem.getType() == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||||
|
listAdapter.insertListItem(listItem, listAdapter.getCount() - 1);
|
||||||
|
} else {
|
||||||
listAdapter.addListItem(listItem);
|
listAdapter.addListItem(listItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package net.osmand.plus.search.listitems;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
|
||||||
|
public class QuickSearchBottomShadowListItem extends QuickSearchListItem {
|
||||||
|
|
||||||
|
public QuickSearchBottomShadowListItem(OsmandApplication app) {
|
||||||
|
super(app, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuickSearchListItemType getType() {
|
||||||
|
return QuickSearchListItemType.BOTTOM_SHADOW;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,5 +5,7 @@ public enum QuickSearchListItemType {
|
||||||
HEADER,
|
HEADER,
|
||||||
BUTTON,
|
BUTTON,
|
||||||
SEARCH_MORE,
|
SEARCH_MORE,
|
||||||
SELECT_ALL
|
SELECT_ALL,
|
||||||
|
TOP_SHADOW,
|
||||||
|
BOTTOM_SHADOW
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package net.osmand.plus.search.listitems;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
|
||||||
|
public class QuickSearchTopShadowListItem extends QuickSearchListItem {
|
||||||
|
|
||||||
|
public QuickSearchTopShadowListItem(OsmandApplication app) {
|
||||||
|
super(app, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuickSearchListItemType getType() {
|
||||||
|
return QuickSearchListItemType.TOP_SHADOW;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue