diff options
author | PauloftheWest <paulofthewest@google.com> | 2014-09-10 06:45:00 -0700 |
---|---|---|
committer | PauloftheWest <paulofthewest@google.com> | 2014-09-11 12:36:58 -0700 |
commit | 8d6991348b79bd2a5878018bd9b28a5da2b6401e (patch) | |
tree | f6489d4138c0f8bdc52d027c5b72859fe305949d /src/com/android/settings/bluetooth/BluetoothSettings.java | |
parent | 1fb5198732d627baf39492651364c32848abc1f0 (diff) | |
download | packages_apps_Settings-8d6991348b79bd2a5878018bd9b28a5da2b6401e.zip packages_apps_Settings-8d6991348b79bd2a5878018bd9b28a5da2b6401e.tar.gz packages_apps_Settings-8d6991348b79bd2a5878018bd9b28a5da2b6401e.tar.bz2 |
Fixed multiple Bluetooth Settings crashes.
+ Fixed a crash when selecting On/Off multiple times on an input device.
+ Fixed a crash when visiting different Bluetooth Settings after
disabling an input device.
Bug: 17402421
Change-Id: I23efa3a36ba8cf0df02cf41397586a10dae9e08c
Diffstat (limited to 'src/com/android/settings/bluetooth/BluetoothSettings.java')
-rwxr-xr-x | src/com/android/settings/bluetooth/BluetoothSettings.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 1282409..826a451 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -392,7 +392,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag(); final Activity activity = getActivity(); - DeviceProfilesSettings profileFrag = (DeviceProfilesSettings)activity. + DeviceProfilesSettings profileFragment = (DeviceProfilesSettings)activity. getFragmentManager().findFragmentById(R.id.bluetooth_fragment_settings); if (mSettingsDialogView != null){ @@ -402,23 +402,26 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } } - if (profileFrag == null) { + if (profileFragment == null) { LayoutInflater inflater = getActivity().getLayoutInflater(); mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_settings, null); - profileFrag = (DeviceProfilesSettings)activity.getFragmentManager() + profileFragment = (DeviceProfilesSettings)activity.getFragmentManager() .findFragmentById(R.id.bluetooth_fragment_settings); // To enable scrolling we store the name field in a seperate header and add to - // the ListView of the profileFrag. + // the ListView of the profileFragment. View header = inflater.inflate(R.layout.bluetooth_device_settings_header, null); - profileFrag.getListView().addHeaderView(header); + profileFragment.getListView().addHeaderView(header); } final View dialogLayout = mSettingsDialogView; AlertDialog.Builder settingsDialog = new AlertDialog.Builder(activity); - profileFrag.setDevice(device); + profileFragment.setDevice(device); final EditText deviceName = (EditText)dialogLayout.findViewById(R.id.name); deviceName.setText(device.getName(), TextView.BufferType.EDITABLE); + + final DeviceProfilesSettings dpsFragment = profileFragment; + final Context context = v.getContext(); settingsDialog.setView(dialogLayout); settingsDialog.setTitle(R.string.bluetooth_preference_paired_devices); settingsDialog.setPositiveButton(R.string.okay, @@ -429,7 +432,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem device.setName(deviceName.getText().toString()); } }); - final Context context = v.getContext(); + settingsDialog.setNegativeButton(R.string.forget, new DialogInterface.OnClickListener() { @Override @@ -442,6 +445,16 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } }); + // We must ensure that the fragment gets destroyed to avoid duplicate fragments. + settingsDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + public void onDismiss(final DialogInterface dialog) { + if (!activity.isDestroyed()) { + activity.getFragmentManager().beginTransaction().remove(dpsFragment) + .commitAllowingStateLoss(); + } + } + }); + AlertDialog dialog = settingsDialog.create(); dialog.create(); dialog.show(); |