mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	added changes for a possibly working emptyCache implementation (needs testing).
This commit is contained in:
		
							parent
							
								
									c43ecda702
								
							
						
					
					
						commit
						e616c80adb
					
				
					 4 changed files with 37 additions and 1 deletions
				
			
		|  | @ -42,4 +42,24 @@ public abstract class PlaceDao { | |||
|                 saveSynchronous(place); | ||||
|             }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Deletes all Place objects from the database. | ||||
|      * | ||||
|      * @return A Completable that completes once the deletion operation is done. | ||||
|      */ | ||||
|     @Query("DELETE FROM place") | ||||
|     public abstract void deleteAllSynchronous(); | ||||
| 
 | ||||
|     /** | ||||
|      * Deletes all Place objects asynchronously from the database. | ||||
|      * | ||||
|      * @return A Completable that completes once the deletion operation is done. | ||||
|      */ | ||||
|     public Completable deleteAll() { | ||||
|         return Completable | ||||
|             .fromAction(() -> { | ||||
|                 deleteAllSynchronous(); | ||||
|             }); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -36,4 +36,8 @@ public class PlacesLocalDataSource { | |||
|     public Completable savePlace(Place place) { | ||||
|         return placeDao.save(place); | ||||
|     } | ||||
| 
 | ||||
|     public Completable clearCache() { | ||||
|         return placeDao.deleteAll(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -38,4 +38,7 @@ public class PlacesRepository { | |||
|         return localDataSource.fetchPlace(entityID); | ||||
|     } | ||||
| 
 | ||||
|     public Completable clearCache() { | ||||
|         return localDataSource.clearCache(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ import android.preference.PreferenceManager; | |||
| import android.provider.Settings; | ||||
| import android.text.Html; | ||||
| import android.text.method.LinkMovementMethod; | ||||
| import android.util.Log; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuInflater; | ||||
|  | @ -319,6 +320,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|             @Override | ||||
|             public boolean onMenuItemClick(MenuItem item) { | ||||
|                 try { | ||||
|                     Timber.d("Reload: menuItem"); | ||||
|                     // REFRESH BUTTON FUNCTIONALITY HERE | ||||
|                     emptyCache(); | ||||
|                     reloadMap(); | ||||
|  | @ -1130,7 +1132,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      *  Reloads the Nearby map | ||||
|      * Reloads the Nearby map. | ||||
|      * This method clears the existing markers, resets the map state, and repopulates the map with the latest data. | ||||
|      */ | ||||
|     private void reloadMap(){ | ||||
| 
 | ||||
|  | @ -1141,7 +1144,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|      *  Empties the Nearby local cache | ||||
|      */ | ||||
|     private void emptyCache(){ | ||||
|         Timber.d("Reload: emptyCache"); | ||||
| 
 | ||||
|         placesRepository.clearCache(); | ||||
| 
 | ||||
|         // Optionally, clear any in-memory cache or state | ||||
|         updatedPlacesList.clear(); | ||||
|         updatedLatLng = null; | ||||
|     } | ||||
| 
 | ||||
|     private void savePlacesAsKML() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Noah Vendrig
						Noah Vendrig