BT device picker: don't rescan after rotating the device
The Bluetooth device picker was restarting the device scan after the screen is rotated. Fix this by only starting the scan when the savedInstanceState Bundle passed to onCreate() is null. Also removes "No Bluetooth devices were found nearby" from list if the user switches to a different app and then switches back to the device picker. Bug: 5249380 Change-Id: I8959c850649eb713fb930ee0a8a7bcb73ca7c1aa
This commit is contained in:
@@ -45,13 +45,13 @@ public class ProgressCategory extends ProgressCategoryBase {
|
||||
textView.setVisibility(noDeviceFound ? View.INVISIBLE : View.VISIBLE);
|
||||
progressBar.setVisibility(mProgress ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
if (mProgress) {
|
||||
if (mProgress || !noDeviceFound) {
|
||||
if (mNoDeviceFoundAdded) {
|
||||
removePreference(mNoDeviceFoundPreference);
|
||||
mNoDeviceFoundAdded = false;
|
||||
}
|
||||
} else {
|
||||
if (noDeviceFound && !mNoDeviceFoundAdded) {
|
||||
if (!mNoDeviceFoundAdded) {
|
||||
if (mNoDeviceFoundPreference == null) {
|
||||
mNoDeviceFoundPreference = new Preference(getContext());
|
||||
mNoDeviceFoundPreference.setLayoutResource(R.layout.preference_empty_list);
|
||||
@@ -70,4 +70,3 @@ public class ProgressCategory extends ProgressCategoryBase {
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
|
||||
private boolean mNeedAuth;
|
||||
private String mLaunchPackage;
|
||||
private String mLaunchClass;
|
||||
private boolean mStartScanOnResume;
|
||||
|
||||
@Override
|
||||
void addPreferencesForActivity() {
|
||||
@@ -50,13 +51,17 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().setTitle(getString(R.string.device_picker));
|
||||
mStartScanOnResume = (savedInstanceState == null); // don't start scan after rotation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
addCachedDevices();
|
||||
mLocalAdapter.startScanning(true);
|
||||
if (mStartScanOnResume) {
|
||||
mLocalAdapter.startScanning(true);
|
||||
mStartScanOnResume = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user