mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 15:23:54 +01:00
Nearby: Complete offline pins implementation
This commit is contained in:
parent
7b154c3dc1
commit
3a38a6636c
4 changed files with 33 additions and 15 deletions
|
|
@ -33,7 +33,7 @@ public abstract class PlaceDao {
|
|||
@Query("SELECT * from place WHERE entityID=:entity")
|
||||
public abstract Place getPlace(String entity);
|
||||
|
||||
@Query("SELECT * from place WHERE latitude>=:latBegin AND longitude>=:lngBegin "
|
||||
@Query("SELECT * from place WHERE name!='' AND latitude>=:latBegin AND longitude>=:lngBegin "
|
||||
+ "AND latitude<:latEnd AND longitude<:lngEnd")
|
||||
public abstract List<Place> fetchPlaces(double latBegin, double lngBegin,
|
||||
double latEnd, double lngEnd);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import io.reactivex.Completable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* The LocalDataSource class for Places
|
||||
|
|
@ -29,7 +30,7 @@ public class PlacesLocalDataSource {
|
|||
return placeDao.getPlace(entityID);
|
||||
}
|
||||
|
||||
public List<Place> fetchPlaces(final LatLng mapTopRight, final LatLng mapBottomLeft) {
|
||||
public List<Place> fetchPlaces(final LatLng mapBottomLeft, final LatLng mapTopRight) {
|
||||
class Constraint {
|
||||
|
||||
final double latBegin;
|
||||
|
|
|
|||
|
|
@ -1852,20 +1852,24 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
clickedMarker.closeInfoWindow();
|
||||
}
|
||||
clickedMarker = marker1;
|
||||
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.VISIBLE);
|
||||
binding.bottomSheetDetails.icon.setVisibility(View.GONE);
|
||||
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.GONE);
|
||||
if (Objects.equals(place.name, "")) {
|
||||
getPlaceData(place.getWikiDataEntityId(), place, marker1, isBookMarked);
|
||||
if (!isNetworkErrorOccurred) {
|
||||
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.VISIBLE);
|
||||
binding.bottomSheetDetails.icon.setVisibility(View.GONE);
|
||||
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.GONE);
|
||||
if (Objects.equals(place.name, "")) {
|
||||
getPlaceData(place.getWikiDataEntityId(), place, marker1, isBookMarked);
|
||||
} else {
|
||||
marker.showInfoWindow();
|
||||
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.GONE);
|
||||
binding.bottomSheetDetails.icon.setVisibility(View.VISIBLE);
|
||||
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.VISIBLE);
|
||||
passInfoToSheet(place);
|
||||
hideBottomSheet();
|
||||
}
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
} else {
|
||||
marker.showInfoWindow();
|
||||
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.GONE);
|
||||
binding.bottomSheetDetails.icon.setVisibility(View.VISIBLE);
|
||||
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.VISIBLE);
|
||||
passInfoToSheet(place);
|
||||
hideBottomSheet();
|
||||
}
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
return true;
|
||||
});
|
||||
return marker;
|
||||
|
|
|
|||
|
|
@ -512,9 +512,22 @@ class NearbyParentFragmentPresenter
|
|||
}
|
||||
}
|
||||
} else {
|
||||
localPlaceSearchJob = scope.launch {
|
||||
loadPlacesDataAyncJob?.cancel()
|
||||
localPlaceSearchJob = scope.launch(Dispatchers.IO) {
|
||||
delay(LOCAL_SCROLL_DELAY)
|
||||
|
||||
val mapFocus = nearbyParentFragmentView.mapFocus
|
||||
val markerPlaceGroups = placesRepository.fetchPlaces(
|
||||
nearbyParentFragmentView.screenBottomLeft,
|
||||
nearbyParentFragmentView.screenTopRight
|
||||
).sortedBy { it.getDistanceInDouble(mapFocus) }.take(NearbyController.MAX_RESULTS)
|
||||
.map {
|
||||
MarkerPlaceGroup(
|
||||
bookmarkLocationDao.findBookmarkLocation(it), it
|
||||
)
|
||||
}
|
||||
ensureActive()
|
||||
NearbyController.currentLocation = mapFocus
|
||||
schedulePlacesUpdate(markerPlaceGroups, force = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue