Search in sources :

Example 26 with MapMarker

use of net.osmand.plus.MapMarkersHelper.MapMarker in project Osmand by osmandapp.

the class MapMarkersActiveAdapter method onItemSwiped.

@Override
public void onItemSwiped(RecyclerView.ViewHolder holder) {
    final int pos = holder.getAdapterPosition();
    final MapMarker marker = getItem(pos);
    mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory(marker);
    MapMarkersHelper.MapMarkersGroup group = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkerGroupById(marker.groupKey);
    if (group != null) {
        mapActivity.getMyApplication().getMapMarkersHelper().updateGroup(group);
    }
    changeMarkers();
    notifyDataSetChanged();
    snackbar = Snackbar.make(holder.itemView, R.string.marker_moved_to_history, Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, pos);
            changeMarkers();
            notifyDataSetChanged();
        }
    });
    AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
    snackbar.show();
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 27 with MapMarker

use of net.osmand.plus.MapMarkersHelper.MapMarker in project Osmand by osmandapp.

the class MapMarkersGroupsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    IconsCache iconsCache = app.getIconsCache();
    if (holder instanceof MapMarkerItemViewHolder) {
        final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
        final MapMarker marker = (MapMarker) getItem(position);
        final boolean markerInHistory = marker.history;
        int color;
        if (marker.history) {
            color = R.color.icon_color_light;
        } else {
            color = MapMarker.getColorId(marker.colorIndex);
        }
        ImageView markerImageViewToUpdate;
        int drawableResToUpdate;
        final boolean markerToHighlight = showDirectionMarkers.contains(marker);
        if (showDirectionEnabled && markerToHighlight) {
            itemViewHolder.iconDirection.setVisibility(View.GONE);
            itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, color));
            itemViewHolder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.list_divider_dark : R.color.markers_top_bar_background));
            itemViewHolder.title.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white));
            itemViewHolder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_divider_color));
            itemViewHolder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_on_map_with_inset));
            itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed, R.color.color_white));
            itemViewHolder.description.setTextColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_color));
            drawableResToUpdate = R.drawable.ic_arrow_marker_diretion;
            markerImageViewToUpdate = itemViewHolder.icon;
        } else {
            itemViewHolder.iconDirection.setVisibility(View.VISIBLE);
            itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
            itemViewHolder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
            itemViewHolder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
            itemViewHolder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
            itemViewHolder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(night ? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset));
            itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed));
            itemViewHolder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
            drawableResToUpdate = R.drawable.ic_direction_arrow;
            markerImageViewToUpdate = itemViewHolder.iconDirection;
        }
        itemViewHolder.title.setText(marker.getName(app));
        boolean noGroup = marker.groupName == null;
        boolean createdEarly = false;
        if (noGroup && !markerInHistory) {
            Calendar currentDateCalendar = Calendar.getInstance();
            currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
            int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
            int currentYear = currentDateCalendar.get(Calendar.YEAR);
            Calendar markerCalendar = Calendar.getInstance();
            markerCalendar.setTimeInMillis(System.currentTimeMillis());
            int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
            int markerYear = markerCalendar.get(Calendar.YEAR);
            createdEarly = currentDay - markerDay >= 2 || currentYear != markerYear;
        }
        if (markerInHistory || createdEarly) {
            itemViewHolder.point.setVisibility(View.VISIBLE);
            itemViewHolder.description.setVisibility(View.VISIBLE);
            Date date;
            if (markerInHistory) {
                date = new Date(marker.visitedDate);
            } else {
                date = new Date(marker.creationDate);
            }
            String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
            if (month.length() > 1) {
                month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
            }
            month = month.replaceAll("\\.", "");
            String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
            itemViewHolder.description.setText(app.getString(R.string.passed, month + " " + day));
        } else {
            itemViewHolder.point.setVisibility(View.GONE);
            itemViewHolder.description.setVisibility(View.GONE);
        }
        itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int position = itemViewHolder.getAdapterPosition();
                if (position < 0) {
                    return;
                }
                if (markerInHistory) {
                    app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
                } else {
                    app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
                }
                updateDisplayedData();
                if (!markerInHistory) {
                    snackbar = Snackbar.make(itemViewHolder.itemView, R.string.marker_moved_to_history, Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {

                        @Override
                        public void onClick(View view) {
                            mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
                            updateDisplayedData();
                        }
                    });
                    AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
                    snackbar.show();
                }
            }
        });
        itemViewHolder.iconReorder.setVisibility(View.GONE);
        itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
        boolean lastItem = position == getItemCount() - 1;
        if ((getItemCount() > position + 1 && getItemViewType(position + 1) == HEADER_TYPE) || lastItem) {
            itemViewHolder.divider.setVisibility(View.GONE);
        } else {
            itemViewHolder.divider.setVisibility(View.VISIBLE);
        }
        itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
        LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
        DashLocationFragment.updateLocationView(useCenter, location, heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0, itemViewHolder.distance, markerLatLon, screenOrientation, app, mapActivity, true);
    } else if (holder instanceof MapMarkerHeaderViewHolder) {
        final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
        final Object header = getItem(position);
        String headerString;
        if (header instanceof Integer) {
            headerViewHolder.icon.setVisibility(View.GONE);
            headerViewHolder.iconSpace.setVisibility(View.VISIBLE);
            Integer dateHeader = (Integer) header;
            if (dateHeader == TODAY_HEADER) {
                headerString = app.getString(R.string.today);
            } else if (dateHeader == YESTERDAY_HEADER) {
                headerString = app.getString(R.string.yesterday);
            } else if (dateHeader == LAST_SEVEN_DAYS_HEADER) {
                headerString = app.getString(R.string.last_seven_days);
            } else if (dateHeader == THIS_YEAR_HEADER) {
                headerString = app.getString(R.string.this_year);
            } else if (dateHeader / 100 == 0) {
                headerString = getMonth(dateHeader);
            } else {
                headerString = String.valueOf(dateHeader);
            }
            headerViewHolder.disableGroupSwitch.setVisibility(View.GONE);
        } else if (header instanceof GroupHeader) {
            final GroupHeader groupHeader = (GroupHeader) header;
            final MapMarkersGroup group = groupHeader.getGroup();
            String groupName = group.getName();
            if (groupName.equals("")) {
                groupName = app.getString(R.string.shared_string_favorites);
            } else if (group.getType() == MapMarkersGroup.GPX_TYPE) {
                groupName = groupName.replace(".gpx", "").replace("/", " ").replace("_", " ");
            }
            if (group.isDisabled()) {
                headerString = groupName;
            } else {
                headerString = groupName + " \u2014 " + group.getActiveMarkers().size() + "/" + group.getMarkers().size();
            }
            headerViewHolder.icon.setVisibility(View.VISIBLE);
            headerViewHolder.iconSpace.setVisibility(View.GONE);
            headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
            boolean groupIsDisabled = group.isDisabled();
            headerViewHolder.disableGroupSwitch.setVisibility(View.VISIBLE);
            CompoundButton.OnCheckedChangeListener checkedChangeListener = new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean enabled) {
                    final MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper();
                    final GPXFile[] gpxFile = new GPXFile[1];
                    boolean disabled = !enabled;
                    boolean synced = false;
                    mapMarkersHelper.updateGroupDisabled(group, disabled);
                    if (group.getType() == MapMarkersGroup.GPX_TYPE) {
                        group.setVisibleUntilRestart(disabled);
                        String gpxPath = group.getId();
                        if (disabled) {
                            SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxPath);
                            if (selectedGpxFile != null) {
                                gpxFile[0] = selectedGpxFile.getGpxFile();
                                switchGpxVisibility(gpxFile[0], false);
                            }
                        } else if (mapMarkersHelper.isGroupSynced(group.getId())) {
                            mapMarkersHelper.runSynchronization(group, true);
                            synced = true;
                        }
                    }
                    if (!synced) {
                        if (mapMarkersHelper.isGroupSynced(group.getId())) {
                            mapMarkersHelper.runSynchronization(group);
                        } else {
                            mapMarkersHelper.addOrEnableGroup(group);
                        }
                    }
                    if (disabled) {
                        snackbar = Snackbar.make(holder.itemView, app.getString(R.string.group_will_be_removed_after_restart), Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {

                            @Override
                            public void onClick(View view) {
                                if (group.getType() == MapMarkersGroup.GPX_TYPE && gpxFile[0] != null) {
                                    switchGpxVisibility(gpxFile[0], true);
                                }
                                mapMarkersHelper.addOrEnableGroup(group);
                            }
                        });
                        AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
                        snackbar.show();
                    }
                }
            };
            headerViewHolder.disableGroupSwitch.setOnCheckedChangeListener(null);
            headerViewHolder.disableGroupSwitch.setChecked(!groupIsDisabled);
            headerViewHolder.disableGroupSwitch.setOnCheckedChangeListener(checkedChangeListener);
        } else {
            throw new IllegalArgumentException("Unsupported header");
        }
        headerViewHolder.title.setText(headerString);
        headerViewHolder.bottomShadow.setVisibility(position == getItemCount() - 1 ? View.VISIBLE : View.GONE);
    } else if (holder instanceof MapMarkersShowHideHistoryViewHolder) {
        final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder;
        final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position);
        final boolean showHistory = showHideHistoryButton.showHistory;
        if (position == getItemCount() - 1) {
            showHideHistoryViewHolder.bottomShadow.setVisibility(View.VISIBLE);
        } else {
            showHideHistoryViewHolder.bottomShadow.setVisibility(View.GONE);
        }
        showHideHistoryViewHolder.title.setText(app.getString(showHistory ? R.string.hide_passed : R.string.show_passed));
        showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                showHideHistoryButton.showHistory = !showHistory;
                createDisplayGroups();
                notifyDataSetChanged();
            }
        });
    }
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) GroupHeader(net.osmand.plus.MapMarkersHelper.GroupHeader) MapMarkersGroup(net.osmand.plus.MapMarkersHelper.MapMarkersGroup) ImageView(android.widget.ImageView) Calendar(java.util.Calendar) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Date(java.util.Date) LatLon(net.osmand.data.LatLon) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ShowHideHistoryButton(net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton) IconsCache(net.osmand.plus.IconsCache) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) SimpleDateFormat(java.text.SimpleDateFormat) CompoundButton(android.widget.CompoundButton)

Example 28 with MapMarker

use of net.osmand.plus.MapMarkersHelper.MapMarker in project Osmand by osmandapp.

the class MapMarkersHistoryAdapter method createHeaders.

public void createHeaders() {
    items = new ArrayList<>();
    List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersHistory();
    int previousHeader = -1;
    int monthsDisplayed = 0;
    Calendar currentDateCalendar = Calendar.getInstance();
    currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
    int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
    int currentMonth = currentDateCalendar.get(Calendar.MONTH);
    int currentYear = currentDateCalendar.get(Calendar.YEAR);
    Calendar markerCalendar = Calendar.getInstance();
    for (int i = 0; i < markersHistory.size(); i++) {
        MapMarker marker = markersHistory.get(i);
        markerCalendar.setTimeInMillis(marker.visitedDate);
        int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
        int markerMonth = markerCalendar.get(Calendar.MONTH);
        int markerYear = markerCalendar.get(Calendar.YEAR);
        if (markerYear == currentYear) {
            if (markerDay == currentDay && previousHeader != TODAY_HEADER) {
                items.add(TODAY_HEADER);
                previousHeader = TODAY_HEADER;
            } else if (markerDay == currentDay - 1 && previousHeader != YESTERDAY_HEADER) {
                items.add(YESTERDAY_HEADER);
                previousHeader = YESTERDAY_HEADER;
            } else if (currentDay - markerDay >= 2 && currentDay - markerDay <= 8 && previousHeader != LAST_SEVEN_DAYS_HEADER) {
                items.add(LAST_SEVEN_DAYS_HEADER);
                previousHeader = LAST_SEVEN_DAYS_HEADER;
            } else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousHeader != markerMonth) {
                items.add(markerMonth);
                previousHeader = markerMonth;
                monthsDisplayed += 1;
            } else if (currentMonth - markerMonth >= 4 && previousHeader != THIS_YEAR_HEADER) {
                items.add(THIS_YEAR_HEADER);
                previousHeader = THIS_YEAR_HEADER;
            }
        } else if (previousHeader != markerYear) {
            items.add(markerYear);
            previousHeader = markerYear;
        }
        items.add(marker);
    }
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) Calendar(java.util.Calendar)

Example 29 with MapMarker

use of net.osmand.plus.MapMarkersHelper.MapMarker in project Osmand by osmandapp.

the class MapMarkersHistoryAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    IconsCache iconsCache = app.getIconsCache();
    if (holder instanceof MapMarkerItemViewHolder) {
        final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
        final MapMarker marker = (MapMarker) getItem(position);
        itemViewHolder.iconReorder.setVisibility(View.GONE);
        int color = R.color.icon_color_light;
        itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
        itemViewHolder.title.setText(marker.getName(app));
        Date date = new Date(marker.visitedDate);
        String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
        if (month.length() > 1) {
            month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
        }
        month = month.replaceAll("\\.", "");
        String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
        String desc = app.getString(R.string.passed, month + " " + day);
        String markerGroupName = marker.groupName;
        if (markerGroupName != null) {
            if (markerGroupName.equals("")) {
                markerGroupName = app.getString(R.string.shared_string_favorites);
            }
            desc += " • " + markerGroupName;
        }
        itemViewHolder.description.setText(desc);
        itemViewHolder.optionsBtn.setBackgroundDrawable(app.getResources().getDrawable(night ? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset));
        itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
        itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int position = itemViewHolder.getAdapterPosition();
                if (position < 0) {
                    return;
                }
                app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
                snackbar = Snackbar.make(itemViewHolder.itemView, app.getString(R.string.marker_moved_to_active), Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
                    }
                });
                AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
                snackbar.show();
            }
        });
        itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
        itemViewHolder.iconDirection.setVisibility(View.GONE);
        itemViewHolder.leftPointSpace.setVisibility(View.GONE);
        itemViewHolder.rightPointSpace.setVisibility(View.GONE);
        boolean lastItem = position == getItemCount() - 1;
        if ((getItemCount() > position + 1 && getItemViewType(position + 1) == HEADER_TYPE) || lastItem) {
            itemViewHolder.divider.setVisibility(View.GONE);
        } else {
            itemViewHolder.divider.setBackgroundColor(ContextCompat.getColor(app, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
            itemViewHolder.divider.setVisibility(View.VISIBLE);
        }
        itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
    } else if (holder instanceof MapMarkerHeaderViewHolder) {
        final MapMarkerHeaderViewHolder dateViewHolder = (MapMarkerHeaderViewHolder) holder;
        final Integer dateHeader = (Integer) getItem(position);
        String dateString;
        if (dateHeader == TODAY_HEADER) {
            dateString = app.getString(R.string.today);
        } else if (dateHeader == YESTERDAY_HEADER) {
            dateString = app.getString(R.string.yesterday);
        } else if (dateHeader == LAST_SEVEN_DAYS_HEADER) {
            dateString = app.getString(R.string.last_seven_days);
        } else if (dateHeader == THIS_YEAR_HEADER) {
            dateString = app.getString(R.string.this_year);
        } else if (dateHeader / 100 == 0) {
            dateString = getMonth(dateHeader);
        } else {
            dateString = String.valueOf(dateHeader);
        }
        dateViewHolder.disableGroupSwitch.setVisibility(View.GONE);
        dateViewHolder.title.setText(dateString);
    }
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Date(java.util.Date) IconsCache(net.osmand.plus.IconsCache) SimpleDateFormat(java.text.SimpleDateFormat)

Example 30 with MapMarker

use of net.osmand.plus.MapMarkersHelper.MapMarker in project Osmand by osmandapp.

the class MapMarkerSelectionFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle bundle = null;
    if (getArguments() != null) {
        bundle = getArguments();
    } else if (savedInstanceState != null) {
        bundle = savedInstanceState;
    }
    if (bundle != null) {
        target = bundle.getBoolean(TARGET_KEY);
        intermediate = bundle.getBoolean(INTERMEDIATE_KEY);
    }
    MapActivity mapActivity = getMapActivity();
    OsmandApplication app = getMyApplication();
    if (mapActivity != null) {
        MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
        onClickListener = routeInfoMenu.getOnMarkerSelectListener();
        screenOrientation = DashLocationFragment.getScreenOrientation(mapActivity);
        MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
        if (trackingUtils != null) {
            Float head = trackingUtils.getHeading();
            float mapRotation = mapActivity.getMapRotate();
            LatLon mw = mapActivity.getMapLocation();
            Location l = trackingUtils.getMyLocation();
            boolean mapLinked = trackingUtils.isMapLinkedToLocation() && l != null;
            LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
            useCenter = !mapLinked;
            loc = (useCenter ? mw : myLoc);
            if (useCenter) {
                heading = -mapRotation;
            } else {
                heading = head;
            }
        }
    }
    nightMode = !app.getSettings().isLightContent();
    View view = inflater.inflate(R.layout.map_marker_selection_fragment, container, false);
    ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton);
    closeButton.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_mode_back));
    closeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
    List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getMapMarkers();
    if (markers.size() > 0) {
        for (MapMarker marker : markers) {
            adapter.add(marker);
        }
    }
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (onClickListener != null) {
                onClickListener.onSelect(position, target, intermediate);
            }
            dismiss();
        }
    });
    return view;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) Bundle(android.os.Bundle) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) MapRouteInfoMenu(net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) MapActivity(net.osmand.plus.activities.MapActivity) Location(net.osmand.Location) Nullable(android.support.annotation.Nullable)

Aggregations

MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)38 LatLon (net.osmand.data.LatLon)20 View (android.view.View)13 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)11 RecyclerView (android.support.v7.widget.RecyclerView)10 OsmandApplication (net.osmand.plus.OsmandApplication)10 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)9 ImageView (android.widget.ImageView)8 Location (net.osmand.Location)8 PointDescription (net.osmand.data.PointDescription)8 Paint (android.graphics.Paint)7 Nullable (android.support.annotation.Nullable)6 MapActivity (net.osmand.plus.activities.MapActivity)6 ArrayList (java.util.ArrayList)5 Amenity (net.osmand.data.Amenity)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)4 FavouritePoint (net.osmand.data.FavouritePoint)4 QuadPoint (net.osmand.data.QuadPoint)4 Bitmap (android.graphics.Bitmap)3