Search in sources :

Example 1 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.

the class TrackDisplayHelper method updateDisplayGroups.

public void updateDisplayGroups() {
    modifiedTime = gpxFile.modifiedTime;
    GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
    displayGroups = filteredGpxFile != null ? selectedGpxHelper.collectDisplayGroups(filteredGpxFile) : selectedGpxHelper.collectDisplayGroups(gpxFile);
    originalGroups.clear();
    for (GpxDisplayGroup g : displayGroups) {
        originalGroups.add(g.cloneInstance());
    }
    if (file != null) {
        SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
        if (sf != null && file != null && sf.getDisplayGroups(app) != null) {
            displayGroups = sf.getDisplayGroups(app);
        }
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)

Example 2 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.

the class TrackPointsCard method updateContent.

@Override
public void updateContent() {
    listView = view.findViewById(android.R.id.list);
    listView.setOnChildClickListener(this);
    List<GpxDisplayGroup> displayGroups = getOriginalGroups();
    adapter.setFilterResults(null);
    adapter.synchronizeGroups(displayGroups);
    if (listView.getAdapter() == null) {
        listView.setAdapter(adapter);
    }
    listView.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            locationDataUpdateAllowed = scrollState == SCROLL_STATE_IDLE;
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    if (actionsView == null) {
        addActions();
    }
    expandAllGroups();
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) OnScrollListener(android.widget.AbsListView.OnScrollListener) AbsListView(android.widget.AbsListView)

Example 3 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.

the class DisplayPointsGroupsHelper method getGroups.

private DisplayGroupsHolder getGroups(@NonNull List<GpxDisplayGroup> displayGroups, @Nullable Set<?> filteredItems) {
    Collections.sort(displayGroups, (g1, g2) -> {
        int i1 = g1.getType().ordinal();
        int i2 = g2.getType().ordinal();
        return Algorithms.compare(i1, i2);
    });
    List<GpxDisplayGroup> trackPointsGroups = new ArrayList<>();
    List<GpxDisplayGroup> routePointsGroups = new ArrayList<>();
    for (GpxDisplayGroup group : displayGroups) {
        if (group.getType() == GpxDisplayItemType.TRACK_POINTS) {
            trackPointsGroups.add(group);
        } else if (group.getType() == GpxDisplayItemType.TRACK_ROUTE_POINTS) {
            routePointsGroups.add(group);
        }
    }
    processDisplayGroups(trackPointsGroups, filteredItems);
    processDisplayGroups(routePointsGroups, filteredItems);
    return new DisplayGroupsHolder(groups, itemGroups);
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) ArrayList(java.util.ArrayList)

Example 4 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.

the class SplitSegmentDialogFragment method updateHeader.

private void updateHeader() {
    final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
    if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) {
        setupSplitIntervalView(splitIntervalView);
        if (options.size() == 0) {
            prepareSplitIntervalAdapterData();
        }
        updateSplitIntervalView(splitIntervalView);
        splitIntervalView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final ListPopupWindow popup = new ListPopupWindow(v.getContext());
                popup.setAnchorView(splitIntervalView);
                popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
                popup.setModal(true);
                popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
                popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
                popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
                popup.setAdapter(new ArrayAdapter<>(v.getContext(), R.layout.popup_list_text_item, options));
                popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        selectedSplitInterval = position;
                        SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), true, false);
                        final List<GpxDisplayGroup> groups = getDisplayGroups();
                        if (groups.size() > 0) {
                            updateSplit(groups, sf);
                        }
                        popup.dismiss();
                        updateSplitIntervalView(splitIntervalView);
                    }
                });
                popup.show();
            }
        });
        splitIntervalView.setVisibility(View.VISIBLE);
    } else {
        splitIntervalView.setVisibility(View.GONE);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) ListPopupWindow(androidx.appcompat.widget.ListPopupWindow) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 5 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup in project Osmand by osmandapp.

the class SplitSegmentDialogFragment method setupSplitIntervalView.

private void setupSplitIntervalView(@NonNull View view) {
    final TextView title = (TextView) view.findViewById(R.id.split_interval_title);
    final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
    final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow);
    boolean nightMode = !app.getSettings().isLightContent();
    int colorId;
    final List<GpxDisplayGroup> groups = getDisplayGroups();
    if (groups.size() > 0) {
        colorId = ColorUtilities.getPrimaryTextColorId(nightMode);
    } else {
        colorId = ColorUtilities.getSecondaryTextColorId(nightMode);
    }
    int color = app.getResources().getColor(colorId);
    title.setTextColor(color);
    String titleText = getString(R.string.gpx_split_interval);
    title.setText(getString(R.string.ltr_or_rtl_combine_via_colon, titleText, ""));
    text.setTextColor(color);
    img.setImageDrawable(ic.getIcon(R.drawable.ic_action_arrow_drop_down, colorId));
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Paint(android.graphics.Paint)

Aggregations

GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)22 ArrayList (java.util.ArrayList)7 GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)7 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 SelectedGpxFile (net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)5 CompoundButton (android.widget.CompoundButton)4 View (android.view.View)3 GPXFile (net.osmand.GPXUtilities.GPXFile)3 WptPt (net.osmand.GPXUtilities.WptPt)3 Paint (android.graphics.Paint)2 AbsListView (android.widget.AbsListView)2 File (java.io.File)2 List (java.util.List)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 DisplayGroupsHolder (net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder)2 DialogInterface (android.content.DialogInterface)1 Drawable (android.graphics.drawable.Drawable)1 SpannableString (android.text.SpannableString)1 OnClickListener (android.view.View.OnClickListener)1