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) {
|
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) {
|
||||||
|
case AppWidgetClassic.NAME: {
|
||||||
appWidgetClassic.performUpdate(MusicService.this, ids);
|
appWidgetClassic.performUpdate(MusicService.this, ids);
|
||||||
} else if (AppWidgetSmall.NAME.equals(command)) {
|
break;
|
||||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
}
|
||||||
|
case AppWidgetSmall.NAME: {
|
||||||
appWidgetSmall.performUpdate(MusicService.this, ids);
|
appWidgetSmall.performUpdate(MusicService.this, ids);
|
||||||
} else if (AppWidgetBig.NAME.equals(command)) {
|
break;
|
||||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
}
|
||||||
|
case AppWidgetBig.NAME: {
|
||||||
appWidgetBig.performUpdate(MusicService.this, ids);
|
appWidgetBig.performUpdate(MusicService.this, ids);
|
||||||
} else if (AppWidgetCard.NAME.equals(command)) {
|
break;
|
||||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
}
|
||||||
|
case AppWidgetCard.NAME: {
|
||||||
appWidgetCard.performUpdate(MusicService.this, ids);
|
appWidgetCard.performUpdate(MusicService.this, ids);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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()) {
|
||||||
|
case EXPANDED:
|
||||||
onPanelSlide(slidingUpPanelLayout, 1);
|
onPanelSlide(slidingUpPanelLayout, 1);
|
||||||
onPanelExpanded(slidingUpPanelLayout);
|
onPanelExpanded(slidingUpPanelLayout);
|
||||||
} else if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
break;
|
||||||
|
case COLLAPSED:
|
||||||
onPanelCollapsed(slidingUpPanelLayout);
|
onPanelCollapsed(slidingUpPanelLayout);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
playerFragment.onHide();
|
playerFragment.onHide();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue