[android] Improved getting the fragment manager whent application is recovering after stopping by system. In some cases (tap fragments are in search) fragment manager of activity is not equal the fragment manager of fragment, so the fragment manager must be obtained always from fragment

This commit is contained in:
alexzatsepin 2020-09-10 18:07:04 +03:00 committed by Arsentiy Milchakov
parent e684c842aa
commit 61013ca2d0

View file

@ -28,9 +28,9 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NavUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@ -725,13 +725,14 @@ public class Utils
public static void detachFragmentIfCoreNotInitialized(@NonNull Context context,
@NonNull Fragment fragment)
{
if (context instanceof AppCompatActivity && !MwmApplication.get().arePlatformAndCoreInitialized())
{
((AppCompatActivity)context).getSupportFragmentManager()
.beginTransaction()
.detach(fragment)
.commit();
}
if (MwmApplication.from(context).arePlatformAndCoreInitialized())
return;
FragmentManager manager = fragment.getFragmentManager();
if (manager == null)
return;
manager.beginTransaction().detach(fragment).commit();
}
public static String capitalize(@Nullable String src)