[android] Fixed crash during setting fragment recovering

This commit is contained in:
Александр Зацепин 2018-11-19 20:19:50 +03:00 committed by yoksnod
parent 5a1212f025
commit 6527ebc543
2 changed files with 18 additions and 10 deletions

View file

@ -1,5 +1,6 @@
package com.mapswithme.maps.settings;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.XmlRes;
@ -11,6 +12,7 @@ import com.mapswithme.maps.R;
import com.mapswithme.util.Config;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
abstract class BaseXmlSettingsFragment extends PreferenceFragmentCompat
{
@ -22,6 +24,13 @@ abstract class BaseXmlSettingsFragment extends PreferenceFragmentCompat
setPreferencesFromResource(getXmlResources(), root);
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
Utils.detachFragmentIfCoreNotInitialized(context, this);
}
@Override
public void onResume()
{

View file

@ -274,11 +274,17 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
return R.xml.prefs_main;
}
@Override
public void onCreate(Bundle savedInstanceState)
private boolean onToggleOptOut(Object newValue)
{
super.onCreate(savedInstanceState);
boolean isEnabled = (boolean) newValue;
Statistics.INSTANCE.trackSettingsToggle(isEnabled);
return true;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
mPreferenceScreen = getPreferenceScreen();
mStoragePref = findPreference(getString(R.string.pref_storage));
mPrefEnabled = (TwoStatePreference) findPreference(getString(R.string.pref_tts_enabled));
@ -309,13 +315,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
updateTts();
}
private boolean onToggleOptOut(Object newValue)
{
boolean isEnabled = (boolean) newValue;
Statistics.INSTANCE.trackSettingsToggle(isEnabled);
return true;
}
@Override
public void onResume()
{