Merge "Make the SwitchBar appear immediately" into lmp-preview-dev

This commit is contained in:
Fabrice Di Meglio
2014-06-12 20:42:23 +00:00
committed by Android (Google) Code Review
13 changed files with 197 additions and 86 deletions

View File

@@ -96,20 +96,26 @@ public class WifiEnabler implements SwitchBar.OnSwitchChangeListener {
mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
}
public void resume(Context context) {
mContext = context;
// Wi-Fi state is sticky, so just let the receiver update UI
mContext.registerReceiver(mReceiver, mIntentFilter);
public void setupSwitchBar() {
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
}
public void pause() {
mContext.unregisterReceiver(mReceiver);
public void teardownSwitchBar() {
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
}
public void resume(Context context) {
mContext = context;
// Wi-Fi state is sticky, so just let the receiver update UI
mContext.registerReceiver(mReceiver, mIntentFilter);
}
public void pause() {
mContext.unregisterReceiver(mReceiver);
}
private void handleWifiStateChanged(int state) {
switch (state) {
case WifiManager.WIFI_STATE_ENABLING:

View File

@@ -404,6 +404,15 @@ public class WifiSettings extends RestrictedSettingsFragment
setHasOptionsMenu(true);
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (mWifiEnabler != null) {
mWifiEnabler.teardownSwitchBar();
}
}
@Override
public void onStart() {
super.onStart();
@@ -414,6 +423,7 @@ public class WifiSettings extends RestrictedSettingsFragment
mSwitchBar = activity.getSwitchBar();
mWifiEnabler = new WifiEnabler(activity, mSwitchBar);
mWifiEnabler.setupSwitchBar();
}
}