diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-05-22 19:29:31 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-05-23 02:33:42 +0000 |
commit | 962a141f4c67fdb02d9062530f5f9e9cfb5e674a (patch) | |
tree | 252af6d2c5fab76a92697013feb43ec2f2aa8a6b /src/com/android/settings/nfc/AndroidBeam.java | |
parent | 474c704221a945b0dc7a0a3676d9bdda2dd5df01 (diff) | |
download | packages_apps_Settings-962a141f4c67fdb02d9062530f5f9e9cfb5e674a.zip packages_apps_Settings-962a141f4c67fdb02d9062530f5f9e9cfb5e674a.tar.gz packages_apps_Settings-962a141f4c67fdb02d9062530f5f9e9cfb5e674a.tar.bz2 |
Fix bug #15173703 Crash in Settings is observed when Android Beam page orientation is changed. DO NOT MERGE
- use onActivityCreated() / onResume() / onPause() for the SwitchBar
Change-Id: I24b346fdc5c19acedbe845d3b7697718412b5e5d
(cherry picked from commit 4c42a88828a8df9e00ce66216fe0ef9f0d89464d)
Diffstat (limited to 'src/com/android/settings/nfc/AndroidBeam.java')
-rw-r--r-- | src/com/android/settings/nfc/AndroidBeam.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java index 2d8d6fe..eb3ff9b 100644 --- a/src/com/android/settings/nfc/AndroidBeam.java +++ b/src/com/android/settings/nfc/AndroidBeam.java @@ -16,6 +16,7 @@ package com.android.settings.nfc; +import android.app.ActionBar; import android.app.Fragment; import android.nfc.NfcAdapter; import android.os.Bundle; @@ -39,12 +40,27 @@ public class AndroidBeam extends Fragment public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - SettingsActivity activity = (SettingsActivity) getActivity(); + final ActionBar actionBar = getActivity().getActionBar(); - mOldActivityTitle = activity.getActionBar().getTitle(); - activity.getActionBar().setTitle(R.string.android_beam_settings_title); + mOldActivityTitle = actionBar.getTitle(); + actionBar.setTitle(R.string.android_beam_settings_title); mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + mView = inflater.inflate(R.layout.android_beam, container, false); + + return mView; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + SettingsActivity activity = (SettingsActivity) getActivity(); mSwitchBar = activity.getSwitchBar(); mSwitch = mSwitchBar.getSwitch(); @@ -52,22 +68,24 @@ public class AndroidBeam extends Fragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - mView = inflater.inflate(R.layout.android_beam, container, false); + public void onResume() { + super.onResume(); mSwitchBar.addOnSwitchChangeListener(this); mSwitchBar.show(); - mSwitch.setChecked(mNfcAdapter.isNdefPushEnabled()); + } - return mView; + @Override + public void onPause() { + super.onPause(); + + mSwitchBar.removeOnSwitchChangeListener(this); + mSwitchBar.hide(); } @Override public void onDestroyView() { super.onDestroyView(); - mSwitchBar.removeOnSwitchChangeListener(this); - mSwitchBar.hide(); if (mOldActivityTitle != null) { getActivity().getActionBar().setTitle(mOldActivityTitle); } |