mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-11-04 08:43:52 +01:00 
			
		
		
		
	Fixed few pins not loading on changing apps
This commit is contained in:
		
							parent
							
								
									13a390a860
								
							
						
					
					
						commit
						79b25734ad
					
				
					 1 changed files with 20 additions and 1 deletions
				
			
		| 
						 | 
					@ -203,6 +203,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
 | 
				
			||||||
    private Place nearestPlace;
 | 
					    private Place nearestPlace;
 | 
				
			||||||
    private volatile boolean stopQuery;
 | 
					    private volatile boolean stopQuery;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<Place> updatedPlaceList;
 | 
				
			||||||
 | 
					    private LatLng updatedLatLng;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ActivityResultLauncher<String[]> inAppCameraLocationPermissionLauncher = registerForActivityResult(
 | 
					    private ActivityResultLauncher<String[]> inAppCameraLocationPermissionLauncher = registerForActivityResult(
 | 
				
			||||||
        new RequestMultiplePermissions(),
 | 
					        new RequestMultiplePermissions(),
 | 
				
			||||||
        new ActivityResultCallback<Map<String, Boolean>>() {
 | 
					        new ActivityResultCallback<Map<String, Boolean>>() {
 | 
				
			||||||
| 
						 | 
					@ -598,6 +601,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
 | 
				
			||||||
            if (locationPermissionsHelper.checkLocationPermission(getActivity())) {
 | 
					            if (locationPermissionsHelper.checkLocationPermission(getActivity())) {
 | 
				
			||||||
                if (lastFocusLocation == null && lastKnownLocation == null) {
 | 
					                if (lastFocusLocation == null && lastKnownLocation == null) {
 | 
				
			||||||
                    locationPermissionGranted();
 | 
					                    locationPermissionGranted();
 | 
				
			||||||
 | 
					                }else if (updatedPlaceList != null){
 | 
				
			||||||
 | 
					                    loadPlacesDataAsync(updatedPlaceList, updatedLatLng);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                startMapWithoutPermission();
 | 
					                startMapWithoutPermission();
 | 
				
			||||||
| 
						 | 
					@ -1433,7 +1438,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
 | 
				
			||||||
    public void loadPlacesDataAsync(List<Place> placeList, LatLng curLatLng) {
 | 
					    public void loadPlacesDataAsync(List<Place> placeList, LatLng curLatLng) {
 | 
				
			||||||
        List<Place> places = new ArrayList<>(placeList);
 | 
					        List<Place> places = new ArrayList<>(placeList);
 | 
				
			||||||
        int batchSize = 3;
 | 
					        int batchSize = 3;
 | 
				
			||||||
        final List<Place> updatedPlaceList = new ArrayList<>(placeList);
 | 
					        updatedLatLng = curLatLng;
 | 
				
			||||||
 | 
					        updatedPlaceList = new ArrayList<>(placeList);
 | 
				
			||||||
        if (VERSION.SDK_INT >= VERSION_CODES.N) {
 | 
					        if (VERSION.SDK_INT >= VERSION_CODES.N) {
 | 
				
			||||||
            Collections.sort(places, Comparator.comparingDouble(place -> place.getDistanceInDouble(curLatLng)));
 | 
					            Collections.sort(places, Comparator.comparingDouble(place -> place.getDistanceInDouble(curLatLng)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -1449,6 +1455,19 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int endIndex = Math.min(startIndex + batchSize, places.size());
 | 
					        int endIndex = Math.min(startIndex + batchSize, places.size());
 | 
				
			||||||
        List<Place> batch = places.subList(startIndex, endIndex);
 | 
					        List<Place> batch = places.subList(startIndex, endIndex);
 | 
				
			||||||
 | 
					        for (int i = 0; i< batch.size(); i++){
 | 
				
			||||||
 | 
					            if (i == batch.size() - 1 && batch.get(i).name != ""){
 | 
				
			||||||
 | 
					                processBatchesSequentially(places, batchSize, updatedPlaceList, curLatLng, endIndex + batchSize);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (batch.get(i).name == ""){
 | 
				
			||||||
 | 
					                if (i == 0){
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                processBatchesSequentially(places, batchSize, updatedPlaceList, curLatLng, endIndex + i);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Disposable disposable = processBatch(batch, updatedPlaceList)
 | 
					        Disposable disposable = processBatch(batch, updatedPlaceList)
 | 
				
			||||||
            .subscribe(p -> {
 | 
					            .subscribe(p -> {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue