Remove unnecessary notify in BT preference
notifyHierarchyChanged() is used before when we have connected/disconnect deivce in same list. So only use it in DevicePickerFragment.java, not other normal fragments. Also that call will rebuild whole preference list, which is heavy. Bug: 119479725 Test: Manual Change-Id: I06cf221588001b38634fec9f02dee8bc1e561ea8
This commit is contained in:
@@ -31,6 +31,7 @@ import android.util.Pair;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
@@ -58,6 +59,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
private AlertDialog mDisconnectDialog;
|
||||
private String contentDescription = null;
|
||||
private boolean mHideSecondTarget = false;
|
||||
@VisibleForTesting
|
||||
boolean mNeedNotifyHierarchyChanged = false;
|
||||
/* Talk-back descriptions for various BT icons */
|
||||
Resources mResources;
|
||||
|
||||
@@ -80,8 +83,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
onDeviceAttributesChanged();
|
||||
}
|
||||
|
||||
void rebind() {
|
||||
notifyChanged();
|
||||
public void setNeedNotifyHierarchyChanged(boolean needNotifyHierarchyChanged) {
|
||||
mNeedNotifyHierarchyChanged = needNotifyHierarchyChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +147,9 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
setVisible(mShowDevicesWithoutNames || mCachedDevice.hasHumanReadableName());
|
||||
|
||||
// This could affect ordering, so notify that
|
||||
notifyHierarchyChanged();
|
||||
if (mNeedNotifyHierarchyChanged) {
|
||||
notifyHierarchyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user