From 0d39173b8bc10f2d94f604e2495621259e2604fd Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 5 Mar 2021 12:38:38 +0200 Subject: [PATCH] add ObjectType.GPX_TRACK --- .../src/main/java/net/osmand/search/core/ObjectType.java | 2 +- .../osmand/plus/activities/search/SearchHistoryFragment.java | 2 -- .../net/osmand/plus/search/QuickSearchDialogFragment.java | 3 +-- OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java | 2 +- .../src/net/osmand/plus/search/QuickSearchListAdapter.java | 3 ++- .../src/net/osmand/plus/search/QuickSearchListFragment.java | 5 +++-- .../osmand/plus/search/listitems/QuickSearchListItem.java | 2 ++ 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java b/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java index c14d5cff07..df81a9ce18 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java @@ -8,7 +8,7 @@ public enum ObjectType { // LOCATION LOCATION(true), PARTIAL_LOCATION(false), // UI OBJECTS - FAVORITE(true), FAVORITE_GROUP(false), WPT(true), RECENT_OBJ(true), + FAVORITE(true), FAVORITE_GROUP(false), WPT(true), RECENT_OBJ(true), GPX_TRACK(false), // ONLINE SEARCH ONLINE_SEARCH(true), diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java index 234f9ec1af..9cb508141e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java @@ -305,8 +305,6 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA iconId = R.drawable.ic_type_video; } else if (pd.isPhotoNote()) { iconId = R.drawable.ic_type_img; - } else if (pd.isGpxFile()) { - iconId = R.drawable.ic_action_polygom_dark; } else { iconId = R.drawable.ic_action_street_name; } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 463db3a6f7..22b75072ec 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -513,8 +513,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC List historyEntries = new ArrayList(); List selectedItems = historySearchFragment.getListAdapter().getSelectedItems(); for (QuickSearchListItem searchListItem : selectedItems) { - SearchResult sr = searchListItem.getSearchResult(); - Object object = sr.object; + Object object = searchListItem.getSearchResult().object;; if (object instanceof HistoryEntry) { historyEntries.add((HistoryEntry) object); } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java index 7a47446fa6..2cf4226e12 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java @@ -464,7 +464,7 @@ public class QuickSearchHelper implements ResourceListener { if (gpxInfo != null) { sr.localeName = gpxInfo.getFileName(); sr.object = point; - sr.objectType = ObjectType.RECENT_OBJ; + sr.objectType = ObjectType.GPX_TRACK; sr.relatedObject = gpxInfo; publish = true; } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 64593b5492..c9a3d1d5e9 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -40,6 +40,7 @@ import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchMoreListItem; import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem; import net.osmand.search.SearchUICore; +import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchPhrase; import net.osmand.search.core.SearchResult; import net.osmand.search.core.SearchWord; @@ -401,7 +402,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { @Nullable View convertView, @NonNull QuickSearchListItem listItem) { SearchResult sr = listItem.getSearchResult(); - if (sr != null && sr.relatedObject instanceof GPXInfo) { + if (sr != null && sr.objectType == ObjectType.GPX_TRACK) { return bindGpxTrack(position, convertView, listItem, (GPXInfo) sr.relatedObject); } else { return bindSearchResult(position, convertView, listItem); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index c9635e7dac..410f011154 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -100,7 +100,8 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { || sr.objectType == ObjectType.FAVORITE || sr.objectType == ObjectType.RECENT_OBJ || sr.objectType == ObjectType.WPT - || sr.objectType == ObjectType.STREET_INTERSECTION) { + || sr.objectType == ObjectType.STREET_INTERSECTION + || sr.objectType == ObjectType.GPX_TRACK) { showResult(sr); } else { @@ -170,7 +171,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { public void showResult(SearchResult searchResult) { showResult = false; - if (searchResult.relatedObject instanceof GPXInfo) { + if (searchResult.objectType == ObjectType.GPX_TRACK) { showTrackMenuFragment((GPXInfo) searchResult.relatedObject); } else if (searchResult.location != null) { OsmandApplication app = getMyApplication(); diff --git a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItem.java b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItem.java index 204c31de88..56b0b7a572 100644 --- a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItem.java +++ b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItem.java @@ -359,6 +359,8 @@ public class QuickSearchListItem { } else { return icon; } + case GPX_TRACK: + return getIcon(app, R.drawable.ic_action_polygom_dark); case LOCATION: return getIcon(app, R.drawable.ic_action_world_globe); case FAVORITE: