mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Apply update list adapter method
This commit is contained in:
		
							parent
							
								
									8fd55538b1
								
							
						
					
					
						commit
						37b5bf7660
					
				
					 3 changed files with 26 additions and 19 deletions
				
			
		|  | @ -78,7 +78,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         resumeFragment(); | ||||
|         bundle = new Bundle(); | ||||
| 
 | ||||
|         initBottomSheetBehaviour(); | ||||
|         //initBottomSheetBehaviour(); | ||||
|         initDrawer(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -379,23 +379,23 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         if (nearbyMapFragment == null) { | ||||
|             lockNearbyView(true); | ||||
|             setMapFragment(); | ||||
| 
 | ||||
|             setListFragment(); | ||||
| 
 | ||||
|             hideProgressBar(); | ||||
|             lockNearbyView(false); | ||||
|         } else { // There are fragments, just update the map and list | ||||
|             updateMapFragment(false); | ||||
| 
 | ||||
|             updateListFragment(); | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         if (nearbyListFragment == null) { | ||||
|         /*if (nearbyListFragment == null) { | ||||
|             lockNearbyView(true); | ||||
|             setListFragment(); | ||||
|             lockNearbyView(false); | ||||
|         } else { | ||||
|             updateListFragment(); | ||||
|         } | ||||
|         }*/ | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|  | @ -449,7 +449,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         * */ | ||||
| 
 | ||||
|         NearbyMapFragment nearbyMapFragment = getMapFragment(); | ||||
|         if (nearbyMapFragment != null) { | ||||
|         if (nearbyMapFragment != null && curLatLang != null) { | ||||
|             // TODO: buradasın eger sınırlara yakınsan significant update yap ve methodların adlarını değiştir. | ||||
|             /* | ||||
|             * If we are close to nearby places boundaries, we need a significant update to | ||||
|  | @ -469,7 +469,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|                         .subscribe(this::populatePlaces); | ||||
|                 nearbyMapFragment.setArguments(bundle); | ||||
|                 nearbyMapFragment.updateMapSignificantly(); | ||||
| 
 | ||||
|                 updateListFragment(); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|  | @ -479,6 +479,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|             } else { | ||||
|                 nearbyMapFragment.setArguments(bundle); | ||||
|                 nearbyMapFragment.updateMapSignificantly(); | ||||
|                 updateListFragment(); | ||||
|             } | ||||
|         } else { | ||||
|             lockNearbyView(true); | ||||
|  | @ -491,6 +492,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|     } | ||||
| 
 | ||||
|     private void updateListFragment() { | ||||
|         nearbyListFragment.setArguments(bundle); | ||||
|         nearbyListFragment.updateNearbyListSignificantly(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -503,6 +505,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         nearbyMapFragment.setArguments(bundle); | ||||
|         fragmentTransaction.replace(R.id.container, nearbyMapFragment, TAG_RETAINED_MAP_FRAGMENT); | ||||
|         fragmentTransaction.commitAllowingStateLoss(); | ||||
|         //hideProgressBar(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -513,6 +516,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         nearbyListFragment = new NearbyListFragment(); | ||||
|         nearbyListFragment.setArguments(bundle); | ||||
|         fragmentTransaction.replace(R.id.container_sheet, nearbyListFragment, TAG_RETAINED_LIST_FRAGMENT); | ||||
|         initBottomSheetBehaviour(); | ||||
|         bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); | ||||
|         fragmentTransaction.commitAllowingStateLoss(); | ||||
|     } | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby; | |||
| 
 | ||||
| import com.pedrogomez.renderers.ListAdapteeCollection; | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| import com.pedrogomez.renderers.RendererAdapter; | ||||
| import com.pedrogomez.renderers.RendererBuilder; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
|  | @ -9,11 +10,6 @@ import java.util.List; | |||
| 
 | ||||
| class NearbyAdapterFactory { | ||||
| 
 | ||||
| 
 | ||||
|     NearbyAdapterFactory(){ | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public RVRendererAdapter<Place> create(List<Place> placeList) { | ||||
|         RendererBuilder<Place> builder = new RendererBuilder<Place>() | ||||
|                 .bind(Place.class, new PlaceRenderer()); | ||||
|  |  | |||
|  | @ -11,6 +11,8 @@ import android.view.ViewGroup; | |||
| import com.google.gson.Gson; | ||||
| import com.google.gson.GsonBuilder; | ||||
| import com.google.gson.reflect.TypeToken; | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| import com.pedrogomez.renderers.RendererAdapter; | ||||
| 
 | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.Collections; | ||||
|  | @ -56,9 +58,19 @@ public class NearbyListFragment extends DaggerFragment { | |||
|     public void onViewCreated(View view, Bundle savedInstanceState) { | ||||
|         // Check that this is the first time view is created, | ||||
|         // to avoid double list when screen orientation changed | ||||
|         Bundle bundle = this.getArguments(); | ||||
|         recyclerView.setAdapter(adapterFactory.create(getPlaceListFromBundle(bundle))); | ||||
|     } | ||||
| 
 | ||||
|     public void updateNearbyListSignificantly() { | ||||
|         Bundle bundle = this.getArguments(); | ||||
|         adapterFactory.updateAdapterData(getPlaceListFromBundle(bundle), | ||||
|                 (RVRendererAdapter<Place>) recyclerView.getAdapter()); | ||||
|     } | ||||
| 
 | ||||
|     private List<Place> getPlaceListFromBundle(Bundle bundle) { | ||||
|         List<Place> placeList = Collections.emptyList(); | ||||
| 
 | ||||
|         Bundle bundle = this.getArguments(); | ||||
|         if (bundle != null) { | ||||
|             String gsonPlaceList = bundle.getString("PlaceList", "[]"); | ||||
|             placeList = gson.fromJson(gsonPlaceList, LIST_TYPE); | ||||
|  | @ -68,11 +80,6 @@ public class NearbyListFragment extends DaggerFragment { | |||
| 
 | ||||
|             placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList); | ||||
|         } | ||||
| 
 | ||||
|         recyclerView.setAdapter(adapterFactory.create(placeList)); | ||||
|     } | ||||
| 
 | ||||
|     public void updateNearbyListSignificantly() { | ||||
|         adapterFactory.updateAdapterData(); | ||||
|         return placeList; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 neslihanturan
						neslihanturan