Fix bug #15086008 NPE observed after user setup device daydream followed by device orientation

- get the Switch reference when the fragment activity has been created
and thus into onActivityCreated(Bundle)

Change-Id: I16c8e42ff225db029d017c392f4273a1fe277a21
This commit is contained in:
Fabrice Di Meglio
2014-05-19 17:30:23 -07:00
parent 3f6d2e422b
commit 28ffbd3ba7

View File

@@ -82,17 +82,11 @@ public class DreamSettings extends SettingsPreferenceFragment implements
logd("onCreate(%s)", icicle); logd("onCreate(%s)", icicle);
super.onCreate(icicle); super.onCreate(icicle);
final SettingsActivity activity = (SettingsActivity) getActivity(); mBackend = new DreamBackend(getActivity());
mBackend = new DreamBackend(activity);
mSwitchBar = activity.getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@Override @Override
public void onSwitchChanged(Switch switchView, boolean isChecked) { public void onSwitchChanged(Switch switchView, boolean isChecked) {
if (!mRefreshing) { if (!mRefreshing) {
@@ -127,6 +121,10 @@ public class DreamSettings extends SettingsPreferenceFragment implements
mAdapter = new DreamInfoAdapter(mContext); mAdapter = new DreamInfoAdapter(mContext);
listView.setAdapter(mAdapter); listView.setAdapter(mAdapter);
final SettingsActivity sa = (SettingsActivity) getActivity();
mSwitchBar = sa.getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
} }
@Override @Override