Search in sources :

Example 16 with GpxDisplayGroup

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

the class TrackAppearanceFragment method applySplit.

void applySplit(GpxSplitType splitType, int timeSplit, double distanceSplit) {
    if (splitIntervalCard != null) {
        splitIntervalCard.updateContent();
    }
    SplitTrackListener splitTrackListener = new SplitTrackListener() {

        @Override
        public void trackSplittingStarted() {
        }

        @Override
        public void trackSplittingFinished() {
            if (selectedGpxFile != null) {
                List<GpxDisplayGroup> groups = getGpxDisplayGroups();
                selectedGpxFile.setDisplayGroups(groups, app);
            }
            refreshMap();
        }
    };
    List<GpxDisplayGroup> groups = getGpxDisplayGroups();
    new SplitTrackAsyncTask(app, splitType, groups, splitTrackListener, trackDrawInfo.isJoinSegments(), timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) SplitTrackAsyncTask(net.osmand.plus.track.SplitTrackAsyncTask) SplitTrackListener(net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener)

Example 17 with GpxDisplayGroup

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

the class TrackMenuFragment method saveGpx.

private void saveGpx(final SelectedGpxFile selectedGpxFile, GPXFile gpxFile) {
    new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() {

        @Override
        public void gpxSavingStarted() {
        }

        @Override
        public void gpxSavingFinished(Exception errorMessage) {
            if (selectedGpxFile != null) {
                List<GpxDisplayGroup> groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] { GpxDisplayItemType.TRACK_SEGMENT });
                selectedGpxFile.setDisplayGroups(groups, app);
                selectedGpxFile.processPoints(app);
            }
            updateContent();
        }
    }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) SaveGpxListener(net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener) SaveGpxAsyncTask(net.osmand.plus.track.SaveGpxAsyncTask) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) File(java.io.File)

Example 18 with GpxDisplayGroup

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

the class DisplayGroupsBottomSheet method updateListItems.

private void updateListItems() {
    listContainer.removeAllViews();
    listViews.clear();
    for (SelectableItem<GpxDisplayGroup> item : uiItems) {
        View view = inflater.inflate(R.layout.bottom_sheet_item_with_descr_and_switch_56dp, listContainer, false);
        TextView title = view.findViewById(R.id.title);
        title.setText(item.getTitle());
        TextView description = view.findViewById(R.id.description);
        description.setText(item.getDescription());
        CompoundButton cb = view.findViewById(R.id.compound_button);
        UiUtilities.setupCompoundButton(cb, nightMode, CompoundButtonType.GLOBAL);
        view.setOnClickListener(v -> {
            GpxDisplayGroup group = item.getObject();
            updateGroupVisibility(group.getName(), !cb.isChecked());
            callback.onPointGroupsVisibilityChanged();
            fullUpdate();
        });
        listContainer.addView(view);
        listViews.put(item, view);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 19 with GpxDisplayGroup

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

the class DisplayGroupsBottomSheet method updateList.

private void updateList() {
    int defaultIconColor = ColorUtilities.getDefaultIconColor(app, nightMode);
    for (SelectableItem<GpxDisplayGroup> item : uiItems) {
        View view = listViews.get(item);
        if (view == null) {
            continue;
        }
        GpxDisplayGroup group = item.getObject();
        boolean isVisible = group != null && !selectedGpxFile.isGroupHidden(group.getName());
        int iconId = isVisible ? R.drawable.ic_action_folder : R.drawable.ic_action_folder_hidden;
        int iconColor = item.getColor();
        if (iconColor == 0 || !isVisible) {
            iconColor = defaultIconColor;
        }
        ImageView icon = view.findViewById(R.id.icon);
        icon.setImageDrawable(getPaintedIcon(iconId, iconColor));
        CompoundButton cb = view.findViewById(R.id.compound_button);
        cb.setChecked(isVisible);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 20 with GpxDisplayGroup

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

the class DisplayPointsGroupsHelper method processDisplayGroups.

private void processDisplayGroups(List<GpxDisplayGroup> displayGroups, Set<?> filteredItems) {
    for (int i = 0; i < displayGroups.size(); i++) {
        GpxDisplayGroup group = displayGroups.get(i);
        if (group.getModifiableList().isEmpty()) {
            continue;
        }
        Map<String, List<GpxDisplayItem>> itemsMap = collectItemsByCategory(group, i);
        if (filteredItems != null) {
            itemsMap = filterItems(itemsMap, filteredItems);
        }
        if (!Algorithms.isEmpty(itemsMap)) {
            setCollectedItems(group, itemsMap);
        }
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) ArrayList(java.util.ArrayList) List(java.util.List)

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