Only hold weak reference
This commit is contained in:
parent
c9986edc5e
commit
3596463bf3
|
@ -14,6 +14,8 @@ import android.view.MenuItem;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.preferences.PreferenceController;
|
import de.danoeh.antennapod.preferences.PreferenceController;
|
||||||
|
@ -26,7 +28,7 @@ public class PreferenceActivity extends ActionBarActivity {
|
||||||
|
|
||||||
private PreferenceController preferenceController;
|
private PreferenceController preferenceController;
|
||||||
private MainFragment prefFragment;
|
private MainFragment prefFragment;
|
||||||
private static PreferenceActivity instance;
|
private static WeakReference<PreferenceActivity> instance;
|
||||||
|
|
||||||
|
|
||||||
private final PreferenceController.PreferenceUI preferenceUI = new PreferenceController.PreferenceUI() {
|
private final PreferenceController.PreferenceUI preferenceUI = new PreferenceController.PreferenceUI() {
|
||||||
|
@ -47,8 +49,8 @@ public class PreferenceActivity extends ActionBarActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
// This must be the FIRST thing we do, otherwise other code may not have the
|
// This must be the FIRST thing we do, otherwise other code may not have the
|
||||||
// reference it needs
|
// reference it needs
|
||||||
instance = this;
|
instance = new WeakReference<PreferenceActivity>(this);
|
||||||
|
|
||||||
setTheme(UserPreferences.getTheme());
|
setTheme(UserPreferences.getTheme());
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
@ -102,16 +104,18 @@ public class PreferenceActivity extends ActionBarActivity {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
if(instance.preferenceController != null) {
|
PreferenceActivity activity = instance.get();
|
||||||
instance.preferenceController.onCreate();
|
if(activity != null && activity.preferenceController != null) {
|
||||||
|
activity.preferenceController.onCreate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if(instance.preferenceController != null) {
|
PreferenceActivity activity = instance.get();
|
||||||
instance.preferenceController.onResume();
|
if(activity != null && activity.preferenceController != null) {
|
||||||
|
activity.preferenceController.onResume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue