2626import fr .free .nrw .commons .auth .AuthenticatedActivity ;
2727import fr .free .nrw .commons .auth .SessionManager ;
2828import fr .free .nrw .commons .location .LocationServiceManager ;
29+ import fr .free .nrw .commons .nearby .NearbyController ;
2930import fr .free .nrw .commons .nearby .NearbyFragment ;
3031import fr .free .nrw .commons .notification .NotificationActivity ;
3132import fr .free .nrw .commons .theme .NavigationBaseActivity ;
@@ -56,8 +57,6 @@ public class ContributionsActivity extends AuthenticatedActivity implements Frag
5657 private final int CONTRIBUTIONS_TAB_POSITION = 0 ;
5758 private final int NEARBY_TAB_POSITION = 1 ;
5859
59- //public ContributionsFragment contributionsFragment;
60- private NearbyFragment nearbyFragment ;
6160 public boolean isContributionsFragmentVisible = true ; // False means nearby fragment is visible
6261 private Menu menu ;
6362 private boolean isThereUnreadNotifications = false ;
@@ -326,7 +325,7 @@ public Fragment getItem(int position) {
326325 retainedContributionsFragment .setMediaDetailPagerFragment ();
327326 }
328327 contributionsFragment = retainedContributionsFragment ;
329- return retainedContributionsFragment ;
328+ return contributionsFragment ;
330329 }
331330
332331 // If we reach here, retainedContributionsFragment is null
@@ -339,10 +338,22 @@ public Fragment getItem(int position) {
339338
340339 return contributionsFragment ;
341340 case 1 :
342- if (getNearbyFragment (1 ) != null ) {
343- return getNearbyFragment (1 );
341+ NearbyFragment retainedNearbyFragment = getNearbyFragment (1 );
342+
343+ if (retainedNearbyFragment != null ) {
344+ nearbyFragment = retainedNearbyFragment ;
345+ return nearbyFragment ;
344346 }
345- return new NearbyFragment ();// nearby places needs photo
347+
348+ // If we reach here, retainedNearbyFragment is null
349+ nearbyFragment = new NearbyFragment ();
350+ String nearbyFragmentTag = makeFragmentName (R .id .pager , 1 );
351+ fragmentManager .beginTransaction ()
352+ .replace (R .id .pager , nearbyFragment , nearbyFragmentTag )
353+ .addToBackStack (nearbyFragmentTag )
354+ .commit ();
355+
356+ return nearbyFragment ;
346357 default :
347358 return null ;
348359 }
0 commit comments