26
26
import fr .free .nrw .commons .auth .AuthenticatedActivity ;
27
27
import fr .free .nrw .commons .auth .SessionManager ;
28
28
import fr .free .nrw .commons .location .LocationServiceManager ;
29
+ import fr .free .nrw .commons .nearby .NearbyController ;
29
30
import fr .free .nrw .commons .nearby .NearbyFragment ;
30
31
import fr .free .nrw .commons .notification .NotificationActivity ;
31
32
import fr .free .nrw .commons .theme .NavigationBaseActivity ;
@@ -56,8 +57,6 @@ public class ContributionsActivity extends AuthenticatedActivity implements Frag
56
57
private final int CONTRIBUTIONS_TAB_POSITION = 0 ;
57
58
private final int NEARBY_TAB_POSITION = 1 ;
58
59
59
- //public ContributionsFragment contributionsFragment;
60
- private NearbyFragment nearbyFragment ;
61
60
public boolean isContributionsFragmentVisible = true ; // False means nearby fragment is visible
62
61
private Menu menu ;
63
62
private boolean isThereUnreadNotifications = false ;
@@ -326,7 +325,7 @@ public Fragment getItem(int position) {
326
325
retainedContributionsFragment .setMediaDetailPagerFragment ();
327
326
}
328
327
contributionsFragment = retainedContributionsFragment ;
329
- return retainedContributionsFragment ;
328
+ return contributionsFragment ;
330
329
}
331
330
332
331
// If we reach here, retainedContributionsFragment is null
@@ -339,10 +338,22 @@ public Fragment getItem(int position) {
339
338
340
339
return contributionsFragment ;
341
340
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 ;
344
346
}
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 ;
346
357
default :
347
358
return null ;
348
359
}
0 commit comments