Make GPX track search result like other search results
This commit is contained in:
parent
8ceab0c5c3
commit
d942a4f683
9 changed files with 41 additions and 58 deletions
|
@ -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), GPX_TRACK(false),
|
||||
FAVORITE(true), FAVORITE_GROUP(false), WPT(true), RECENT_OBJ(true),
|
||||
|
||||
// ONLINE SEARCH
|
||||
ONLINE_SEARCH(true),
|
||||
|
|
|
@ -303,8 +303,10 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
|||
iconId = R.drawable.ic_type_audio;
|
||||
} else if (pd.isVideoNote()) {
|
||||
iconId = R.drawable.ic_type_video;
|
||||
}else if (pd.isPhotoNote()) {
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ import net.osmand.plus.poi.RearrangePoiFiltersFragment;
|
|||
import net.osmand.plus.resources.RegionAddressRepository;
|
||||
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
|
||||
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchGpxTrackListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
|
@ -118,7 +117,6 @@ import java.util.List;
|
|||
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_LOCATION_KEY;
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_QUERY_KEY;
|
||||
import static net.osmand.search.core.ObjectType.GPX_TRACK;
|
||||
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
||||
import static net.osmand.search.core.ObjectType.SEARCH_STARTED;
|
||||
import static net.osmand.search.core.SearchCoreFactory.SEARCH_AMENITY_TYPE_PRIORITY;
|
||||
|
@ -516,7 +514,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
|
||||
for (QuickSearchListItem searchListItem : selectedItems) {
|
||||
SearchResult sr = searchListItem.getSearchResult();
|
||||
Object object = sr.objectType == GPX_TRACK ? sr.relatedObject : sr.object;
|
||||
Object object = sr.object;
|
||||
if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
}
|
||||
|
@ -1235,7 +1233,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (res != null) {
|
||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
addListItem(rows, sr);
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
|
||||
app.getString(R.string.search_online_address), new OnClickListener() {
|
||||
|
@ -1502,7 +1500,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
int limit = 15;
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
if (limit > 0) {
|
||||
addListItem(rows, sr);
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
limit--;
|
||||
}
|
||||
|
@ -1542,7 +1540,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
if (res != null) {
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
addListItem(rows, sr);
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
}
|
||||
historySearchFragment.updateListAdapter(rows, false);
|
||||
|
@ -1553,14 +1551,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
private void addListItem(List<QuickSearchListItem> rows, SearchResult sr) {
|
||||
if (sr.objectType == GPX_TRACK) {
|
||||
rows.add(new QuickSearchGpxTrackListItem(app, sr));
|
||||
} else {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreSearch() {
|
||||
if (addressSearch) {
|
||||
startAddressSearch();
|
||||
|
@ -2062,7 +2052,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
if (res != null && res.getCurrentSearchResults().size() > 0) {
|
||||
for (final SearchResult sr : res.getCurrentSearchResults()) {
|
||||
addListItem(rows, sr);
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
updateSendEmptySearchBottomBar(false);
|
||||
}
|
||||
|
|
|
@ -463,9 +463,9 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
GPXInfo gpxInfo = GpxUiHelper.getGpxInfoByFileName(app, pd.getName());
|
||||
if (gpxInfo != null) {
|
||||
sr.localeName = gpxInfo.getFileName();
|
||||
sr.object = gpxInfo;
|
||||
sr.objectType = ObjectType.GPX_TRACK;
|
||||
sr.relatedObject = point;
|
||||
sr.object = point;
|
||||
sr.objectType = ObjectType.RECENT_OBJ;
|
||||
sr.relatedObject = gpxInfo;
|
||||
publish = true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -227,8 +227,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
return bindTopShadowItem(convertView);
|
||||
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||
return bindBottomShadowItem(convertView);
|
||||
} else if (type == QuickSearchListItemType.GPX_TRACK) {
|
||||
view = bindGpxTrackItem(position, convertView, listItem);
|
||||
} else {
|
||||
view = bindSearchResultItem(position, convertView, listItem);
|
||||
}
|
||||
|
@ -399,18 +397,29 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
return getLinearLayout(convertView, R.layout.list_shadow_footer);
|
||||
}
|
||||
|
||||
private LinearLayout bindGpxTrackItem(int position,
|
||||
private LinearLayout bindSearchResultItem(int position,
|
||||
@Nullable View convertView,
|
||||
@NonNull QuickSearchListItem listItem) {
|
||||
SearchResult sr = listItem.getSearchResult();
|
||||
if (sr != null && sr.relatedObject instanceof GPXInfo) {
|
||||
return bindGpxTrack(position, convertView, listItem, (GPXInfo) sr.relatedObject);
|
||||
} else {
|
||||
return bindSearchResult(position, convertView, listItem);
|
||||
}
|
||||
}
|
||||
|
||||
private LinearLayout bindGpxTrack(int position,
|
||||
@Nullable View convertView,
|
||||
@NonNull QuickSearchListItem listItem,
|
||||
@NonNull GPXInfo gpxInfo) {
|
||||
LinearLayout view = getLinearLayout(convertView, R.layout.search_gpx_list_item);
|
||||
SearchResult sr = listItem.getSearchResult();
|
||||
GPXInfo gpxInfo = (GPXInfo) sr.object;
|
||||
setupCheckBox(position, view, listItem);
|
||||
GpxUiHelper.updateGpxInfoView(app, view, sr.localeName, listItem.getIcon(), gpxInfo);
|
||||
return view;
|
||||
}
|
||||
|
||||
private LinearLayout bindSearchResultItem(int position,
|
||||
private LinearLayout bindSearchResult(int position,
|
||||
@Nullable View convertView,
|
||||
@NonNull QuickSearchListItem listItem) {
|
||||
LinearLayout view = getLinearLayout(convertView, R.layout.search_list_item);
|
||||
|
@ -502,12 +511,17 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
}
|
||||
|
||||
private LinearLayout getLinearLayout(@Nullable View convertView, int layoutId) {
|
||||
if (convertView == null) {
|
||||
if (convertView == null || isLayoutIdChanged(convertView, layoutId)) {
|
||||
convertView = inflater.inflate(layoutId, null);
|
||||
convertView.setTag(layoutId);
|
||||
}
|
||||
return (LinearLayout) convertView;
|
||||
}
|
||||
|
||||
private boolean isLayoutIdChanged(@NonNull View view, int layoutId) {
|
||||
return !Algorithms.objectEquals(view.getTag(), layoutId);
|
||||
}
|
||||
|
||||
private void setupCheckBox(final int position,
|
||||
@NonNull View rootView,
|
||||
@NonNull QuickSearchListItem listItem) {
|
||||
|
@ -579,8 +593,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
selectedItems.clear();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
QuickSearchListItemType t = getItem(i).getType();
|
||||
if (t == QuickSearchListItemType.SEARCH_RESULT
|
||||
|| t == QuickSearchListItemType.GPX_TRACK) {
|
||||
if (t == QuickSearchListItemType.SEARCH_RESULT) {
|
||||
selectedItems.add(getItem(i));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,11 +109,6 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
}
|
||||
dialogFragment.completeQueryWithObject(sr);
|
||||
}
|
||||
} else if (item.getType() == QuickSearchListItemType.GPX_TRACK) {
|
||||
SearchResult sr = item.getSearchResult();
|
||||
if (sr.objectType == ObjectType.GPX_TRACK) {
|
||||
showTrackMenuFragment((GPXInfo) sr.object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +170,9 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
|
||||
public void showResult(SearchResult searchResult) {
|
||||
showResult = false;
|
||||
if (searchResult.location != null) {
|
||||
if (searchResult.relatedObject instanceof GPXInfo) {
|
||||
showTrackMenuFragment((GPXInfo) searchResult.relatedObject);
|
||||
} else if (searchResult.location != null) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
|
||||
boolean transliterate = searchResult.requiredSearchPhrase.getSettings().isTransliterate();
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package net.osmand.plus.search.listitems;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.search.core.SearchResult;
|
||||
|
||||
public class QuickSearchGpxTrackListItem extends QuickSearchListItem {
|
||||
|
||||
public QuickSearchGpxTrackListItem(OsmandApplication app, SearchResult searchResult) {
|
||||
super(app, searchResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuickSearchListItemType getType() {
|
||||
return QuickSearchListItemType.GPX_TRACK;
|
||||
}
|
||||
}
|
|
@ -382,8 +382,6 @@ public class QuickSearchListItem {
|
|||
case WPT:
|
||||
WptPt wpt = (WptPt) searchResult.object;
|
||||
return PointImageDrawable.getFromWpt(app, wpt.getColor(), false, wpt);
|
||||
case GPX_TRACK:
|
||||
return getIcon(app, R.drawable.ic_action_polygom_dark);
|
||||
case UNKNOWN_NAME_FILTER:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.search.listitems;
|
|||
|
||||
public enum QuickSearchListItemType {
|
||||
SEARCH_RESULT,
|
||||
GPX_TRACK,
|
||||
HEADER,
|
||||
BUTTON,
|
||||
SEARCH_MORE,
|
||||
|
|
Loading…
Reference in a new issue