Replace if blocks with switch blocks
This commit is contained in:
parent
99ff2a3914
commit
2d173acc3f
2 changed files with 29 additions and 19 deletions
|
|
@ -1272,18 +1272,24 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
public void onReceive(final Context context, final Intent intent) {
|
||||
final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME);
|
||||
|
||||
if (AppWidgetClassic.NAME.equals(command)) {
|
||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
appWidgetClassic.performUpdate(MusicService.this, ids);
|
||||
} else if (AppWidgetSmall.NAME.equals(command)) {
|
||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
appWidgetSmall.performUpdate(MusicService.this, ids);
|
||||
} else if (AppWidgetBig.NAME.equals(command)) {
|
||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
appWidgetBig.performUpdate(MusicService.this, ids);
|
||||
} else if (AppWidgetCard.NAME.equals(command)) {
|
||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
appWidgetCard.performUpdate(MusicService.this, ids);
|
||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
switch (command) {
|
||||
case AppWidgetClassic.NAME: {
|
||||
appWidgetClassic.performUpdate(MusicService.this, ids);
|
||||
break;
|
||||
}
|
||||
case AppWidgetSmall.NAME: {
|
||||
appWidgetSmall.performUpdate(MusicService.this, ids);
|
||||
break;
|
||||
}
|
||||
case AppWidgetBig.NAME: {
|
||||
appWidgetBig.performUpdate(MusicService.this, ids);
|
||||
break;
|
||||
}
|
||||
case AppWidgetCard.NAME: {
|
||||
appWidgetCard.performUpdate(MusicService.this, ids);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,13 +81,17 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
public void onGlobalLayout() {
|
||||
slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
|
||||
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||
onPanelSlide(slidingUpPanelLayout, 1);
|
||||
onPanelExpanded(slidingUpPanelLayout);
|
||||
} else if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||
onPanelCollapsed(slidingUpPanelLayout);
|
||||
} else {
|
||||
playerFragment.onHide();
|
||||
switch (getPanelState()) {
|
||||
case EXPANDED:
|
||||
onPanelSlide(slidingUpPanelLayout, 1);
|
||||
onPanelExpanded(slidingUpPanelLayout);
|
||||
break;
|
||||
case COLLAPSED:
|
||||
onPanelCollapsed(slidingUpPanelLayout);
|
||||
break;
|
||||
default:
|
||||
playerFragment.onHide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue