Replace if blocks with switch blocks

This commit is contained in:
Eugene Cheung 2018-09-05 22:46:30 -04:00
commit 2d173acc3f
No known key found for this signature in database
GPG key ID: E1FD745328866B0A
2 changed files with 29 additions and 19 deletions

View file

@ -1272,18 +1272,24 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME); final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME);
if (AppWidgetClassic.NAME.equals(command)) { final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); switch (command) {
appWidgetClassic.performUpdate(MusicService.this, ids); case AppWidgetClassic.NAME: {
} else if (AppWidgetSmall.NAME.equals(command)) { appWidgetClassic.performUpdate(MusicService.this, ids);
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); break;
appWidgetSmall.performUpdate(MusicService.this, ids); }
} else if (AppWidgetBig.NAME.equals(command)) { case AppWidgetSmall.NAME: {
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); appWidgetSmall.performUpdate(MusicService.this, ids);
appWidgetBig.performUpdate(MusicService.this, ids); break;
} else if (AppWidgetCard.NAME.equals(command)) { }
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); case AppWidgetBig.NAME: {
appWidgetCard.performUpdate(MusicService.this, ids); appWidgetBig.performUpdate(MusicService.this, ids);
break;
}
case AppWidgetCard.NAME: {
appWidgetCard.performUpdate(MusicService.this, ids);
break;
}
} }
} }
}; };

View file

@ -81,13 +81,17 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
public void onGlobalLayout() { public void onGlobalLayout() {
slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) { switch (getPanelState()) {
onPanelSlide(slidingUpPanelLayout, 1); case EXPANDED:
onPanelExpanded(slidingUpPanelLayout); onPanelSlide(slidingUpPanelLayout, 1);
} else if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { onPanelExpanded(slidingUpPanelLayout);
onPanelCollapsed(slidingUpPanelLayout); break;
} else { case COLLAPSED:
playerFragment.onHide(); onPanelCollapsed(slidingUpPanelLayout);
break;
default:
playerFragment.onHide();
break;
} }
} }
}); });