use of net.osmand.plus.helpers.SearchHistoryHelper in project Osmand by osmandapp.
the class DashRecentsFragment method setupRecents.
public void setupRecents() {
View mainView = getView();
SearchHistoryHelper helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity().getApplicationContext());
points = helper.getHistoryEntries();
arrows.clear();
if (points.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
LinearLayout recents = (LinearLayout) mainView.findViewById(R.id.items);
recents.removeAllViews();
DashboardOnMap.handleNumberOfRows(points, getMyApplication().getSettings(), ROW_NUMBER_TAG);
LatLon loc = getDefaultLocation();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final HistoryEntry historyEntry : points) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.search_history_list_item, null, false);
SearchHistoryFragment.udpateHistoryItem(historyEntry, view, loc, getActivity(), getMyApplication());
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
((ImageView) view.findViewById(R.id.navigate_to)).setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_gdirections_dark));
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), historyEntry.getLat(), historyEntry.getLon(), historyEntry.getName());
}
});
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getSettings().setMapLocationToShow(historyEntry.getLat(), historyEntry.getLon(), 15, historyEntry.getName(), true, // $NON-NLS-1$
historyEntry);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
DashLocationView dv = new DashLocationView((ImageView) view.findViewById(R.id.direction), (TextView) view.findViewById(R.id.distance), new LatLon(historyEntry.getLat(), historyEntry.getLon()));
distances.add(dv);
recents.addView(view);
}
this.distances = distances;
}
Aggregations