mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Nearby Fix disappearing of pins loaded from cache Fixes #6052 * Remove outdated tests --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
4b152fc15f
commit
4dd16054ca
4 changed files with 20 additions and 15 deletions
|
|
@ -20,4 +20,8 @@ public class MarkerPlaceGroup {
|
|||
public boolean getIsBookmarked() {
|
||||
return isBookmarked;
|
||||
}
|
||||
|
||||
public void setIsBookmarked(boolean isBookmarked) {
|
||||
this.isBookmarked = isBookmarked;
|
||||
}
|
||||
}
|
||||
|
|
@ -1839,7 +1839,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
);
|
||||
}
|
||||
|
||||
public Marker convertToMarker(Place place, Boolean isBookMarked) {
|
||||
public Marker convertToMarker(Place place, boolean isBookMarked) {
|
||||
Drawable icon = ContextCompat.getDrawable(getContext(), getIconFor(place, isBookMarked));
|
||||
GeoPoint point = new GeoPoint(place.location.getLatitude(), place.location.getLongitude());
|
||||
Marker marker = new Marker(binding.map);
|
||||
|
|
|
|||
|
|
@ -105,12 +105,15 @@ class NearbyParentFragmentPresenter
|
|||
*
|
||||
* @see SchedulePlacesUpdateOptions
|
||||
*/
|
||||
private suspend fun schedulePlacesUpdate(markerPlaceGroups: List<MarkerPlaceGroup>) =
|
||||
private suspend fun schedulePlacesUpdate(
|
||||
markerPlaceGroups: List<MarkerPlaceGroup>,
|
||||
force: Boolean = false
|
||||
) =
|
||||
withContext(Dispatchers.Main) {
|
||||
if (markerPlaceGroups.isEmpty()) return@withContext
|
||||
schedulePlacesUpdateJob?.cancel()
|
||||
schedulePlacesUpdateJob = launch {
|
||||
if (SchedulePlacesUpdateOptions.skippedCount++
|
||||
if (!force && SchedulePlacesUpdateOptions.skippedCount++
|
||||
< SchedulePlacesUpdateOptions.SKIP_LIMIT
|
||||
) {
|
||||
delay(SchedulePlacesUpdateOptions.SKIP_DELAY_MS)
|
||||
|
|
@ -298,8 +301,6 @@ class NearbyParentFragmentPresenter
|
|||
lockUnlockNearby(false) // So that new location updates wont come
|
||||
nearbyParentFragmentView.setProgressBarVisibility(false)
|
||||
|
||||
updatePlaceGroupsToControllerAndRender(nearbyPlaceGroups)
|
||||
|
||||
loadPlacesDataAyncJob = scope?.launch(Dispatchers.IO) {
|
||||
// clear past clicks and bookmarkChanged queues
|
||||
clickedPlaces.clear()
|
||||
|
|
@ -312,18 +313,20 @@ class NearbyParentFragmentPresenter
|
|||
val indicesToUpdate = mutableListOf<Int>()
|
||||
for (i in 0..updatedGroups.lastIndex) {
|
||||
val repoPlace = placesRepository.fetchPlace(updatedGroups[i].place.entityID)
|
||||
if (repoPlace != null && repoPlace.name != ""){
|
||||
updatedGroups[i] = MarkerPlaceGroup(
|
||||
bookmarkLocationDao.findBookmarkLocation(repoPlace),
|
||||
repoPlace
|
||||
)
|
||||
if (repoPlace != null && repoPlace.name != null && repoPlace.name != ""){
|
||||
updatedGroups[i].isBookmarked = bookmarkLocationDao.findBookmarkLocation(repoPlace)
|
||||
updatedGroups[i].place.apply {
|
||||
name = repoPlace.name
|
||||
isMonument = repoPlace.isMonument
|
||||
pic = repoPlace.pic ?: ""
|
||||
exists = repoPlace.exists ?: true
|
||||
longDescription = repoPlace.longDescription ?: ""
|
||||
}
|
||||
} else {
|
||||
indicesToUpdate.add(i)
|
||||
}
|
||||
}
|
||||
if (indicesToUpdate.size < updatedGroups.size) {
|
||||
schedulePlacesUpdate(updatedGroups)
|
||||
}
|
||||
schedulePlacesUpdate(updatedGroups, force = true)
|
||||
// channel for lists of indices of places, each list to be fetched in a single request
|
||||
val fetchPlacesChannel = Channel<List<Int>>(Channel.UNLIMITED)
|
||||
var totalBatches = 0
|
||||
|
|
|
|||
|
|
@ -465,8 +465,6 @@ class NearbyParentFragmentPresenterTest {
|
|||
|
||||
whenever(bookmarkLocationsDao.allBookmarksLocations).thenReturn(Collections.emptyList())
|
||||
nearbyPresenter.updateMapMarkers(nearbyPlacesInfo.placeList, latestLocation, null)
|
||||
Mockito.verify(nearbyParentFragmentView).setFilterState()
|
||||
Mockito.verify(nearbyParentFragmentView).setProgressBarVisibility(false)
|
||||
Mockito.verify(nearbyParentFragmentView).updateListFragment(nearbyPlacesInfo.placeList)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue