diff options
-rw-r--r-- | src/com/android/settings/bluetooth/BluetoothEnabler.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java index 70a8097..1907cd1 100644 --- a/src/com/android/settings/bluetooth/BluetoothEnabler.java +++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java @@ -21,6 +21,8 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Handler; +import android.os.Message; import android.provider.Settings; import android.widget.CompoundButton; import android.widget.Switch; @@ -42,6 +44,22 @@ public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeLis private final LocalBluetoothAdapter mLocalAdapter; private final IntentFilter mIntentFilter; + private static final String EVENT_DATA_IS_BT_ON = "is_bluetooth_on"; + private static final int EVENT_UPDATE_INDEX = 0; + + private Handler mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case EVENT_UPDATE_INDEX: + final boolean isBluetoothOn = msg.getData().getBoolean(EVENT_DATA_IS_BT_ON); + Index.getInstance(mContext).updateFromClassNameResource( + BluetoothSettings.class.getName(), true, isBluetoothOn); + break; + } + } + }; + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -165,7 +183,11 @@ public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeLis } private void updateSearchIndex(boolean isBluetoothOn) { - Index.getInstance(mContext).updateFromClassNameResource( - BluetoothSettings.class.getName(), false, isBluetoothOn); + mHandler.removeMessages(EVENT_UPDATE_INDEX); + + Message msg = new Message(); + msg.what = EVENT_UPDATE_INDEX; + msg.getData().putBoolean(EVENT_DATA_IS_BT_ON, isBluetoothOn); + mHandler.sendMessage(msg); } } |