Skip to content

Commit

Permalink
Merge pull request #21930 from osmandapp/rzr-travel-spinner
Browse files Browse the repository at this point in the history
Add cancellable progress spinner in GpxFileReader (TravelObfHelper)
  • Loading branch information
Chumva authored Feb 20, 2025
2 parents 6341e83 + 783bb82 commit 0e93f53
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class HeightDataLoader {
public static final int ZOOM_TO_LOAD_TILES_SHIFT_L = ZOOM_TO_LOAD_TILES + 1;
public static final int ZOOM_TO_LOAD_TILES_SHIFT_R = 31 - ZOOM_TO_LOAD_TILES;

public interface InterfaceIsCancelled {
public interface Cancellable {
boolean isCancelled();
}

public interface InterfaceCancellableCallback<T> {
boolean callback(T object, InterfaceIsCancelled canceller);
public interface CancellableCallback<T> {
boolean callback(T object, Cancellable canceller);
}

private final static Log log = PlatformUtil.getLog(HeightDataLoader.class);
Expand All @@ -50,7 +50,7 @@ public HeightDataLoader(BinaryMapIndexReader[] readers) {
}
}

public List<WptPt> loadHeightDataAsWaypoints(long osmId, QuadRect bbox31, InterfaceIsCancelled canceller) {
public List<WptPt> loadHeightDataAsWaypoints(long osmId, QuadRect bbox31, Cancellable canceller) {
Map<Long, RouteDataObject> results = new HashMap<>();
ResultMatcher<RouteDataObject> matcher = new ResultMatcher<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ List<Amenity> searchAmenitiesOnThePath(List<Location> locations, double radius,
ResultMatcher<Amenity> matcher);

File getFile();

List<BinaryMapPoiReaderAdapter.PoiRegion> getReaderPoiIndexes();

void searchMapIndex(BinaryMapIndexReader.SearchRequest<BinaryMapDataObject> sr);

void searchPoi(BinaryMapIndexReader.SearchRequest<Amenity> amenitySearchRequest);

List<Amenity> searchPoiByName(BinaryMapIndexReader.SearchRequest<Amenity> searchRequest);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import androidx.annotation.Nullable;

import net.osmand.CallbackWithObject;
import net.osmand.binary.HeightDataLoader.InterfaceCancellableCallback;
import net.osmand.binary.HeightDataLoader.CancellableCallback;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseLoadAsyncTask;

public class ClickableWayAsyncTask extends BaseLoadAsyncTask<Void, Void, ClickableWay> {
private final ClickableWay clickableWay;
private final InterfaceCancellableCallback<ClickableWay> readHeightData;
private final CancellableCallback<ClickableWay> readHeightData;
private final CallbackWithObject<ClickableWay> openAsGpxFile;

public ClickableWayAsyncTask(@NonNull MapActivity mapActivity,
@NonNull ClickableWay clickableWay,
@NonNull InterfaceCancellableCallback<ClickableWay> readHeightData,
@NonNull CancellableCallback<ClickableWay> readHeightData,
@NonNull CallbackWithObject<ClickableWay> openAsGpxFile) {
super(mapActivity);
this.clickableWay = clickableWay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import net.osmand.NativeLibrary.RenderedObject;
import net.osmand.binary.HeightDataLoader;
import net.osmand.binary.HeightDataLoader.InterfaceIsCancelled;
import net.osmand.binary.HeightDataLoader.Cancellable;
import net.osmand.binary.ObfConstants;
import net.osmand.core.jni.ObfMapObject;
import net.osmand.core.jni.QVectorPointI;
Expand All @@ -34,7 +34,6 @@
import net.osmand.shared.gpx.primitives.WptPt;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.osm.OsmRouteType;

import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -201,7 +200,7 @@ private boolean isClickableWayTags(@NonNull Map<String, String> tags) {
return false;
}

private boolean readHeightData(@Nullable ClickableWay clickableWay, @Nullable InterfaceIsCancelled canceller) {
private boolean readHeightData(@Nullable ClickableWay clickableWay, @Nullable Cancellable canceller) {
if (clickableWay != null) {
HeightDataLoader loader = new HeightDataLoader(app.getResourceManager().getReverseGeocodingMapFiles());
List<WptPt> waypoints =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import androidx.annotation.Nullable;

import net.osmand.CallbackWithObject;
import net.osmand.binary.HeightDataLoader.InterfaceCancellableCallback;
import net.osmand.binary.HeightDataLoader.CancellableCallback;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
Expand All @@ -20,11 +20,11 @@

public class ClickableWayMenuProvider implements ContextMenuLayer.IContextMenuProvider {
private final OsmandMapTileView view;
private final InterfaceCancellableCallback<ClickableWay> readHeightData;
private final CancellableCallback<ClickableWay> readHeightData;
private final CallbackWithObject<ClickableWay> openAsGpxFile;

public ClickableWayMenuProvider(@NonNull OsmandMapTileView view,
@NonNull InterfaceCancellableCallback<ClickableWay> readHeightData,
@NonNull CancellableCallback<ClickableWay> readHeightData,
@NonNull CallbackWithObject<ClickableWay> openAsGpxFile) {
this.view = view;
this.readHeightData = readHeightData;
Expand Down
Loading

0 comments on commit 0e93f53

Please sign in to comment.