Search in sources :

Example 1 with SearchHistoryHelper

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;
}
Also used : ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LatLon(net.osmand.data.LatLon) SearchHistoryHelper(net.osmand.plus.helpers.SearchHistoryHelper) LayoutInflater(android.view.LayoutInflater) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 LatLon (net.osmand.data.LatLon)1 SearchHistoryHelper (net.osmand.plus.helpers.SearchHistoryHelper)1 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)1