Skip to content

Commit

Permalink
Limit places
Browse files Browse the repository at this point in the history
  • Loading branch information
vshcherb committed Feb 22, 2025
1 parent d239b29 commit 31723f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
// TODO display all data downloaded even if maps are not loaded
// TODO: why recreate provider when new points are loaded? that causes blinking
// TODO: scheduleImageRefreshes in layer is incorrect it starts downloading all images and stops interacting
//. images for download should be correctly calculated before schedule based on overlap
// TODO images shouldn't be queried if they are not visible in all lists! size doesn't matter !
// TODO show on map close button is not visible
// TODO layer sometimes becomes non-interactive - MAP FPS drops
// TODO Context menu doesn't work correctly and duplicates actual POI
// TODO compass is not rotating
// Extra: display new categories from web
public class ExplorePlacesProviderJava implements ExplorePlacesProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

public class NearbyPlacesCard extends FrameLayout implements ExplorePlacesProvider.ExplorePlacesListener {

private static final int DISPLAY_ITEMS = 25;
private boolean collapsed;
private ImageView explicitIndicator;
private View titleContainer;
Expand Down Expand Up @@ -81,7 +82,7 @@ private void setupRecyclerView() {
nearByList.setLayoutManager(layoutManager);
nearByList.setItemAnimator(null);
visiblePlacesRect = app.getOsmandMap().getMapView().getCurrentRotatedTileBox().getLatLonBounds();
adapter = new NearbyPlacesAdapter(app, app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect), false, clickListener);
adapter = new NearbyPlacesAdapter(app, app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect, DISPLAY_ITEMS), false, clickListener);
nearByList.setAdapter(adapter);
}

Expand All @@ -97,7 +98,7 @@ private void updateExpandState() {

private NearbyPlacesAdapter getNearbyAdapter() {
if (adapter == null) {
List<ExploreTopPlacePoint> nearbyData = app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect);
List<ExploreTopPlacePoint> nearbyData = app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect, DISPLAY_ITEMS);
adapter = new NearbyPlacesAdapter(app, nearbyData, false, clickListener);
}
return adapter;
Expand All @@ -107,7 +108,7 @@ private NearbyPlacesAdapter getNearbyAdapter() {
public void onNewExplorePlacesDownloaded() {
isLoadingItems = false;
AndroidUiHelper.updateVisibility(progressBar, app.getExplorePlacesProvider().isLoading());
adapter.setItems(app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect));
adapter.setItems(app.getExplorePlacesProvider().getDataCollection(visiblePlacesRect, DISPLAY_ITEMS));
adapter.notifyDataSetChanged();
updateExpandState();
}
Expand All @@ -131,7 +132,8 @@ private void onNearbyPlacesCollapseChanged() {
private void startLoadingNearbyPlaces() {
isLoadingItems = true;
app.getExplorePlacesProvider().getDataCollection(
app.getOsmandMap().getMapView().getCurrentRotatedTileBox().getLatLonBounds()
app.getOsmandMap().getMapView().getCurrentRotatedTileBox().getLatLonBounds(),
DISPLAY_ITEMS
);
AndroidUiHelper.updateVisibility(progressBar, app.getExplorePlacesProvider().isLoading());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,14 @@ public LatLon getObjectLocation(Object o) {

private void scheduleImageRefreshes(List<ExploreTopPlacePoint> nearbyPlacePoints) {
Picasso.get().cancelTag(LOAD_NEARBY_IMAGES_TAG);

List<ExploreTopPlacePoint> nearbyPlacePointsList = new ArrayList<>();
int ind = 0;
for (ExploreTopPlacePoint point : nearbyPlacePoints) {
nearbyPlacePointsList.add(point);
if (!Algorithms.isEmpty(point.getIconUrl()) && ind ++ < TOP_LOAD_PHOTOS) {
Target imgLoadTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
point.setImageBitmap(bitmap);
LOG.info(String.format("Picasso loaded %s", point.getIconUrl()));
imagesUpdatedVersion++;
}

Expand Down

0 comments on commit 31723f6

Please sign in to comment.