mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Created refresh button icon, and added it to the nearby_fragment_menu.xml (header of the nearby page). Created function refresh() in NearbyParentFragment.java to handle refresh functionality.
This commit is contained in:
		
							parent
							
								
									8fc7dbbfd1
								
							
						
					
					
						commit
						f3e1bdbb54
					
				
					 3 changed files with 54 additions and 0 deletions
				
			
		|  | @ -311,9 +311,22 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | ||||||
|     public void onCreateOptionsMenu(@NonNull final Menu menu, |     public void onCreateOptionsMenu(@NonNull final Menu menu, | ||||||
|         @NonNull final MenuInflater inflater) { |         @NonNull final MenuInflater inflater) { | ||||||
|         inflater.inflate(R.menu.nearby_fragment_menu, menu); |         inflater.inflate(R.menu.nearby_fragment_menu, menu); | ||||||
|  |         MenuItem refreshButton = menu.findItem(R.id.item_refresh); | ||||||
|         MenuItem listMenu = menu.findItem(R.id.list_sheet); |         MenuItem listMenu = menu.findItem(R.id.list_sheet); | ||||||
|         MenuItem saveAsGPXButton = menu.findItem(R.id.list_item_gpx); |         MenuItem saveAsGPXButton = menu.findItem(R.id.list_item_gpx); | ||||||
|         MenuItem saveAsKMLButton = menu.findItem(R.id.list_item_kml); |         MenuItem saveAsKMLButton = menu.findItem(R.id.list_item_kml); | ||||||
|  |         refreshButton.setOnMenuItemClickListener(new OnMenuItemClickListener() { | ||||||
|  |             @Override | ||||||
|  |             public boolean onMenuItemClick(MenuItem item) { | ||||||
|  |                 try { | ||||||
|  |                     // REFRESH BUTTON FUNCTIONALITY HERE | ||||||
|  |                     refresh(); // handle functionality of refreshing | ||||||
|  |                 } catch (Exception e) { | ||||||
|  |                     throw new RuntimeException(e); | ||||||
|  |                 } | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|         listMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { |         listMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { | ||||||
|             @Override |             @Override | ||||||
|             public boolean onMenuItemClick(MenuItem item) { |             public boolean onMenuItemClick(MenuItem item) { | ||||||
|  | @ -1115,6 +1128,21 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      *  Empties the Nearby local cache and reloads the Nearby map | ||||||
|  |      */ | ||||||
|  |     private void refresh(){ | ||||||
|  |         // can either use this sort of progressDialog to display while page is refreshing | ||||||
|  |         // or, we can put a big fat refresh icon on the page. | ||||||
|  |         // If we stick with the progressDialog, we should make a new one called refreshDialog, | ||||||
|  |         // since itll interfere with the one used to save as GPX/KML | ||||||
|  | 
 | ||||||
|  |         // When the map initially loads, there is already a big fat refresh circle that is displayed so maybe itll be good to use that instead of dialog | ||||||
|  | //        progressDialog.setTitle("REFRESHING NEARBY"); // PLACEHOLDER UNTIL WE | ||||||
|  | //        progressDialog.show(); | ||||||
|  | //        progressDialog.hide(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private void savePlacesAsKML() { |     private void savePlacesAsKML() { | ||||||
|         final Observable<String> savePlacesObservable = Observable |         final Observable<String> savePlacesObservable = Observable | ||||||
|             .fromCallable(() -> nearbyController |             .fromCallable(() -> nearbyController | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								app/src/main/res/drawable/ic_refresh_24dp_nearby.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/src/main/res/drawable/ic_refresh_24dp_nearby.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |   android:width="@dimen/half_standard_height" | ||||||
|  |   android:height="@dimen/half_standard_height" | ||||||
|  |   android:viewportHeight="24.0" | ||||||
|  |   android:viewportWidth="24.0"> | ||||||
|  | 
 | ||||||
|  |     <group | ||||||
|  |       android:scaleX="1.0" | ||||||
|  |     android:scaleY="1.0" | ||||||
|  |     android:translateX="-0.0" | ||||||
|  |     android:translateY="-0.0"> | ||||||
|  | 
 | ||||||
|  |     <path | ||||||
|  |       android:fillColor="?attr/menu_item_tint" | ||||||
|  |       android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/> | ||||||
|  | 
 | ||||||
|  | </group> | ||||||
|  |   </vector> | ||||||
|  | @ -1,17 +1,25 @@ | ||||||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | <menu xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|   xmlns:app="http://schemas.android.com/apk/res-auto"> |   xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||||
| 
 | 
 | ||||||
|  |   <item android:id="@+id/item_refresh" | ||||||
|  |     android:title="Refresh" | ||||||
|  |     app:showAsAction="ifRoom" | ||||||
|  |     android:icon="@drawable/ic_refresh_24dp_nearby" /> | ||||||
|  | 
 | ||||||
|   <item android:id="@+id/list_sheet" |   <item android:id="@+id/list_sheet" | ||||||
|     android:title="@string/list_sheet" |     android:title="@string/list_sheet" | ||||||
|     app:showAsAction="ifRoom|withText" |     app:showAsAction="ifRoom|withText" | ||||||
|     android:icon="@drawable/ic_list_white_24dp" |     android:icon="@drawable/ic_list_white_24dp" | ||||||
|     /> |     /> | ||||||
|  | 
 | ||||||
|   <item android:id="@+id/list_item_gpx" |   <item android:id="@+id/list_item_gpx" | ||||||
|     android:layout_width="wrap_content" |     android:layout_width="wrap_content" | ||||||
|     android:layout_height="wrap_content" |     android:layout_height="wrap_content" | ||||||
|     android:title="Save as GPX file" /> |     android:title="Save as GPX file" /> | ||||||
|  | 
 | ||||||
|   <item android:id="@+id/list_item_kml" |   <item android:id="@+id/list_item_kml" | ||||||
|     android:layout_width="wrap_content" |     android:layout_width="wrap_content" | ||||||
|     android:layout_height="wrap_content" |     android:layout_height="wrap_content" | ||||||
|     android:title="Save as KML file" /> |     android:title="Save as KML file" /> | ||||||
|  | 
 | ||||||
| </menu> | </menu> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Noah Vendrig
						Noah Vendrig