small code refactor within player fragments

This commit is contained in:
dkanada 2021-06-16 13:17:43 +09:00
commit 2054f712be
2 changed files with 4 additions and 11 deletions

View file

@ -305,18 +305,15 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) { public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
switch (newState) { switch (newState) {
case COLLAPSED: case COLLAPSED:
onPanelCollapsed(panel); resetToCurrentPosition();
break; break;
case ANCHORED: case ANCHORED:
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); // this fixes a bug where the panel would get stuck for some reason // this fixes a bug where the panel would get stuck for some reason
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
break; break;
} }
} }
public void onPanelCollapsed(View panel) {
resetToCurrentPosition();
}
private void resetToCurrentPosition() { private void resetToCurrentPosition() {
binding.playerRecyclerView.stopScroll(); binding.playerRecyclerView.stopScroll();
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0); layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);

View file

@ -303,7 +303,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) { public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
switch (newState) { switch (newState) {
case COLLAPSED: case COLLAPSED:
onPanelCollapsed(panel); resetToCurrentPosition();
break; break;
case ANCHORED: case ANCHORED:
// this fixes a bug where the panel would get stuck for some reason // this fixes a bug where the panel would get stuck for some reason
@ -312,10 +312,6 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
} }
} }
public void onPanelCollapsed(View panel) {
resetToCurrentPosition();
}
private void resetToCurrentPosition() { private void resetToCurrentPosition() {
binding.playerRecyclerView.stopScroll(); binding.playerRecyclerView.stopScroll();
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0); layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);