mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Prevent crash caused child fragment is actually null by checking if it is attached or not.
This commit is contained in:
parent
d0556419f7
commit
f4321d0541
2 changed files with 15 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.nearby.mvp.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
|
@ -104,6 +105,12 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
|||
viewsAreReadyCallback.nearbyFragmentAndMapViewReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
((NearbyParentFragment)getParentFragment()).childMapFragmentAttached();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapView setupMapView(Bundle savedInstanceState) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
resumeFragment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can
|
||||
* prevent NPE caused by null child fragment. This method is called from child fragment when
|
||||
* it is attached.
|
||||
*/
|
||||
public void childMapFragmentAttached() {
|
||||
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter(this, nearbyMapFragment);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue