Make the SwitchBar appear immediately

- change the way the SwitchBar is shown and hidden
- save its state
- remove the delay transition code

Change-Id: I07260430e6709b42517ca011f6d3c3446a626731
This commit is contained in:
Fabrice Di Meglio
2014-06-11 20:14:15 -07:00
parent 601aad2022
commit 138ff8c045
13 changed files with 197 additions and 86 deletions

View File

@@ -89,6 +89,16 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
}
public void setupSwitchBar() {
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
}
public void teardownSwitchBar() {
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
}
public void resume(Context context) {
if (mLocalAdapter == null) {
mSwitch.setEnabled(false);
@@ -103,8 +113,6 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
handleStateChanged(mLocalAdapter.getBluetoothState());
mContext.registerReceiver(mReceiver, mIntentFilter);
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
mValidListener = true;
}
@@ -114,8 +122,6 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
}
mContext.unregisterReceiver(mReceiver);
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
mValidListener = false;
}