From ad2ea0b8071931037607e28734049d5006ff873d Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:58:41 -0500 Subject: [PATCH] Lint: 'if' replaceable with 'switch' --- .../fragments/detail/VideoDetailFragment.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index b9140c41c..8e445572d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1346,19 +1346,24 @@ public final class VideoDetailFragment broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { - if (intent.getAction().equals(ACTION_SHOW_MAIN_PLAYER)) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); - } else if (intent.getAction().equals(ACTION_HIDE_MAIN_PLAYER)) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); - } else if (intent.getAction().equals(ACTION_PLAYER_STARTED)) { - // If the state is not hidden we don't need to show the mini player - if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); - } - // Rebound to the service if it was closed via notification or mini player - if (!PlayerHolder.bound) { - PlayerHolder.startService(App.getApp(), false, VideoDetailFragment.this); - } + switch (intent.getAction()) { + case ACTION_SHOW_MAIN_PLAYER: + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); + break; + case ACTION_HIDE_MAIN_PLAYER: + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + break; + case ACTION_PLAYER_STARTED: + // If the state is not hidden we don't need to show the mini player + if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + } + // Rebound to the service if it was closed via notification or mini player + if (!PlayerHolder.bound) { + PlayerHolder.startService( + App.getApp(), false, VideoDetailFragment.this); + } + break; } } };