use view binding for card player fragment
This commit is contained in:
parent
e32e0f03cf
commit
4fd2ce1308
1 changed files with 65 additions and 93 deletions
|
|
@ -9,12 +9,9 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -22,10 +19,9 @@ import android.view.View;
|
||||||
import android.view.ViewAnimationUtils;
|
import android.view.ViewAnimationUtils;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
|
import com.dkanada.gramophone.databinding.FragmentCardPlayerBinding;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
|
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
||||||
|
|
@ -51,29 +47,8 @@ import com.dkanada.gramophone.util.ViewUtil;
|
||||||
import com.dkanada.gramophone.views.WidthFitSquareLayout;
|
import com.dkanada.gramophone.views.WidthFitSquareLayout;
|
||||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.Unbinder;
|
|
||||||
|
|
||||||
public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener {
|
public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks, SlidingUpPanelLayout.PanelSlideListener {
|
||||||
|
FragmentCardPlayerBinding binding;
|
||||||
private Unbinder unbinder;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.toolbar_container)
|
|
||||||
FrameLayout toolbarContainer;
|
|
||||||
@BindView(R.id.player_toolbar)
|
|
||||||
Toolbar toolbar;
|
|
||||||
@BindView(R.id.player_sliding_layout)
|
|
||||||
SlidingUpPanelLayout slidingUpPanelLayout;
|
|
||||||
@BindView(R.id.player_recycler_view)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.playing_queue_card)
|
|
||||||
CardView playingQueueCard;
|
|
||||||
@BindView(R.id.color_background)
|
|
||||||
View colorBackground;
|
|
||||||
@BindView(R.id.player_queue_sub_header)
|
|
||||||
TextView playerQueueSubHeader;
|
|
||||||
|
|
||||||
private int lastColor;
|
private int lastColor;
|
||||||
|
|
||||||
|
|
@ -91,15 +66,15 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentCardPlayerBinding.inflate(inflater);
|
||||||
|
|
||||||
if (Util.isLandscape(getResources())) {
|
if (Util.isLandscape(getResources())) {
|
||||||
impl = new LandscapeImpl(this);
|
impl = new LandscapeImpl(this, binding);
|
||||||
} else {
|
} else {
|
||||||
impl = new PortraitImpl(this);
|
impl = new PortraitImpl(this, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.fragment_card_player, container, false);
|
return binding.getRoot();
|
||||||
unbinder = ButterKnife.bind(this, view);
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -113,8 +88,8 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
|
|
||||||
slidingUpPanelLayout.addPanelSlideListener(this);
|
binding.playerSlidingLayout.addPanelSlideListener(this);
|
||||||
slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));
|
binding.playerSlidingLayout.setAntiDragView(view.findViewById(R.id.draggable_area));
|
||||||
|
|
||||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -125,33 +100,30 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
});
|
});
|
||||||
|
|
||||||
// for some reason the xml attribute doesn't get applied here.
|
// for some reason the xml attribute doesn't get applied here.
|
||||||
playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
|
binding.playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (slidingUpPanelLayout != null) {
|
binding.playerSlidingLayout.removePanelSlideListener(this);
|
||||||
slidingUpPanelLayout.removePanelSlideListener(this);
|
|
||||||
}
|
|
||||||
if (recyclerViewDragDropManager != null) {
|
if (recyclerViewDragDropManager != null) {
|
||||||
recyclerViewDragDropManager.release();
|
recyclerViewDragDropManager.release();
|
||||||
recyclerViewDragDropManager = null;
|
recyclerViewDragDropManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recyclerView != null) {
|
binding.playerRecyclerView.setItemAnimator(null);
|
||||||
recyclerView.setItemAnimator(null);
|
binding.playerRecyclerView.setAdapter(null);
|
||||||
recyclerView.setAdapter(null);
|
|
||||||
recyclerView = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wrappedAdapter != null) {
|
if (wrappedAdapter != null) {
|
||||||
WrapperAdapterUtils.releaseAll(wrappedAdapter);
|
WrapperAdapterUtils.releaseAll(wrappedAdapter);
|
||||||
wrappedAdapter = null;
|
wrappedAdapter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
playingQueueAdapter = null;
|
playingQueueAdapter = null;
|
||||||
layoutManager = null;
|
layoutManager = null;
|
||||||
|
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
unbinder.unbind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -159,13 +131,14 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
if (recyclerViewDragDropManager != null) {
|
if (recyclerViewDragDropManager != null) {
|
||||||
recyclerViewDragDropManager.cancelDrag();
|
recyclerViewDragDropManager.cancelDrag();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
checkToggleToolbar(toolbarContainer);
|
checkToggleToolbar(binding.toolbarContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -189,16 +162,16 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
private void updateQueue() {
|
private void updateQueue() {
|
||||||
playingQueueAdapter.swapDataSet(MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition());
|
playingQueueAdapter.swapDataSet(MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition());
|
||||||
playerQueueSubHeader.setText(getUpNextAndQueueTime());
|
binding.playerQueueSubHeader.setText(getUpNextAndQueueTime());
|
||||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
if (binding.playerSlidingLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||||
resetToCurrentPosition();
|
resetToCurrentPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateQueuePosition() {
|
private void updateQueuePosition() {
|
||||||
playingQueueAdapter.setCurrent(MusicPlayerRemote.getPosition());
|
playingQueueAdapter.setCurrent(MusicPlayerRemote.getPosition());
|
||||||
playerQueueSubHeader.setText(getUpNextAndQueueTime());
|
binding.playerQueueSubHeader.setText(getUpNextAndQueueTime());
|
||||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
if (binding.playerSlidingLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||||
resetToCurrentPosition();
|
resetToCurrentPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,10 +189,10 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpPlayerToolbar() {
|
private void setUpPlayerToolbar() {
|
||||||
toolbar.inflateMenu(R.menu.menu_player);
|
binding.playerToolbar.inflateMenu(R.menu.menu_player);
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
|
binding.playerToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
|
||||||
toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
|
binding.playerToolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
|
||||||
toolbar.setOnMenuItemClickListener(this);
|
binding.playerToolbar.setOnMenuItemClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpRecyclerView() {
|
private void setUpRecyclerView() {
|
||||||
|
|
@ -237,11 +210,11 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
layoutManager = new LinearLayoutManager(getActivity());
|
layoutManager = new LinearLayoutManager(getActivity());
|
||||||
|
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
binding.playerRecyclerView.setLayoutManager(layoutManager);
|
||||||
recyclerView.setAdapter(wrappedAdapter);
|
binding.playerRecyclerView.setAdapter(wrappedAdapter);
|
||||||
recyclerView.setItemAnimator(animator);
|
binding.playerRecyclerView.setItemAnimator(animator);
|
||||||
|
|
||||||
recyclerViewDragDropManager.attachRecyclerView(recyclerView);
|
recyclerViewDragDropManager.attachRecyclerView(binding.playerRecyclerView);
|
||||||
|
|
||||||
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
|
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +224,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
int res = favorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_border_white_24dp;
|
int res = favorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_border_white_24dp;
|
||||||
int color = ToolbarContentTintHelper.toolbarContentColor(getActivity(), Color.TRANSPARENT);
|
int color = ToolbarContentTintHelper.toolbarContentColor(getActivity(), Color.TRANSPARENT);
|
||||||
Drawable drawable = ImageUtil.getTintedVectorDrawable(getActivity(), res, color);
|
Drawable drawable = ImageUtil.getTintedVectorDrawable(getActivity(), res, color);
|
||||||
toolbar.getMenu().findItem(R.id.action_toggle_favorite)
|
binding.playerToolbar.getMenu().findItem(R.id.action_toggle_favorite)
|
||||||
.setIcon(drawable)
|
.setIcon(drawable)
|
||||||
.setTitle(favorite ? getString(R.string.action_remove_from_favorites) : getString(R.string.action_add_to_favorites));
|
.setTitle(favorite ? getString(R.string.action_remove_from_favorites) : getString(R.string.action_add_to_favorites));
|
||||||
}
|
}
|
||||||
|
|
@ -292,11 +265,8 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
boolean wasExpanded = false;
|
boolean wasExpanded = binding.playerSlidingLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED;
|
||||||
if (slidingUpPanelLayout != null) {
|
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||||
wasExpanded = slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED;
|
|
||||||
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
return wasExpanded;
|
return wasExpanded;
|
||||||
}
|
}
|
||||||
|
|
@ -315,14 +285,14 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onToolbarToggled() {
|
public void onToolbarToggled() {
|
||||||
toggleToolbar(toolbarContainer);
|
toggleToolbar(binding.toolbarContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPanelSlide(View view, float slide) {
|
public void onPanelSlide(View view, float slide) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
float density = getResources().getDisplayMetrics().density;
|
float density = getResources().getDisplayMetrics().density;
|
||||||
playingQueueCard.setCardElevation((6 * slide + 2) * density);
|
binding.playingQueueCard.setCardElevation((6 * slide + 2) * density);
|
||||||
playbackControlsFragment.binding.playerPlayPauseFab.setElevation((2 * Math.max(0, (1 - (slide * 16))) + 2) * density);
|
playbackControlsFragment.binding.playerPlayPauseFab.setElevation((2 * Math.max(0, (1 - (slide * 16))) + 2) * density);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -334,7 +304,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
onPanelCollapsed(panel);
|
onPanelCollapsed(panel);
|
||||||
break;
|
break;
|
||||||
case ANCHORED:
|
case ANCHORED:
|
||||||
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); // this fixes a bug where the panel would get stuck for some reason
|
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); // this fixes a bug where the panel would get stuck for some reason
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +314,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetToCurrentPosition() {
|
private void resetToCurrentPosition() {
|
||||||
recyclerView.stopScroll();
|
binding.playerRecyclerView.stopScroll();
|
||||||
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
|
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,9 +330,11 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
private static abstract class BaseImpl implements Impl {
|
private static abstract class BaseImpl implements Impl {
|
||||||
protected CardPlayerFragment fragment;
|
protected CardPlayerFragment fragment;
|
||||||
|
protected FragmentCardPlayerBinding binding;
|
||||||
|
|
||||||
public BaseImpl(CardPlayerFragment fragment) {
|
public BaseImpl(CardPlayerFragment fragment, FragmentCardPlayerBinding binding) {
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
|
this.binding = binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
|
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
|
||||||
|
|
@ -372,11 +344,11 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
int x = (int) (fragment.playbackControlsFragment.binding.playerPlayPauseFab.getX() + fragment.playbackControlsFragment.binding.playerPlayPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
|
int x = (int) (fragment.playbackControlsFragment.binding.playerPlayPauseFab.getX() + fragment.playbackControlsFragment.binding.playerPlayPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
|
||||||
int y = (int) (fragment.playbackControlsFragment.binding.playerPlayPauseFab.getY() + fragment.playbackControlsFragment.binding.playerPlayPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY() + fragment.playbackControlsFragment.binding.playerProgressSlider.getHeight());
|
int y = (int) (fragment.playbackControlsFragment.binding.playerPlayPauseFab.getY() + fragment.playbackControlsFragment.binding.playerPlayPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY() + fragment.playbackControlsFragment.binding.playerProgressSlider.getHeight());
|
||||||
float startRadius = Math.max(fragment.playbackControlsFragment.binding.playerPlayPauseFab.getWidth() / 2, fragment.playbackControlsFragment.binding.playerPlayPauseFab.getHeight() / 2);
|
float startRadius = Math.max(fragment.playbackControlsFragment.binding.playerPlayPauseFab.getWidth() / 2, fragment.playbackControlsFragment.binding.playerPlayPauseFab.getHeight() / 2);
|
||||||
float endRadius = Math.max(fragment.colorBackground.getWidth(), fragment.colorBackground.getHeight());
|
float endRadius = Math.max(binding.colorBackground.getWidth(), binding.colorBackground.getHeight());
|
||||||
fragment.colorBackground.setBackgroundColor(newColor);
|
binding.colorBackground.setBackgroundColor(newColor);
|
||||||
backgroundAnimator = ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius);
|
backgroundAnimator = ViewAnimationUtils.createCircularReveal(binding.colorBackground, x, y, startRadius, endRadius);
|
||||||
} else {
|
} else {
|
||||||
backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, newColor);
|
backgroundAnimator = ViewUtil.createBackgroundColorTransition(binding.colorBackground, fragment.lastColor, newColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatorSet animatorSet = new AnimatorSet();
|
AnimatorSet animatorSet = new AnimatorSet();
|
||||||
|
|
@ -386,7 +358,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
|
if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
|
||||||
int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
|
int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
|
||||||
int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
|
int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
|
||||||
Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
|
Animator subHeaderAnimator = ViewUtil.createTextColorTransition(binding.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
|
||||||
animatorSet.play(subHeaderAnimator);
|
animatorSet.play(subHeaderAnimator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -397,7 +369,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
@Override
|
@Override
|
||||||
public void animateColorChange(int newColor) {
|
public void animateColorChange(int newColor) {
|
||||||
if (ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
|
if (ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
|
||||||
fragment.playerQueueSubHeader.setTextColor(ThemeStore.textColorSecondary(fragment.getActivity()));
|
binding.playerQueueSubHeader.setTextColor(ThemeStore.textColorSecondary(fragment.getActivity()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -407,8 +379,8 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
MediaEntryViewHolder currentSongViewHolder;
|
MediaEntryViewHolder currentSongViewHolder;
|
||||||
Song currentSong = Song.EMPTY_SONG;
|
Song currentSong = Song.EMPTY_SONG;
|
||||||
|
|
||||||
public PortraitImpl(CardPlayerFragment fragment) {
|
public PortraitImpl(CardPlayerFragment fragment, FragmentCardPlayerBinding binding) {
|
||||||
super(fragment);
|
super(fragment, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -422,10 +394,10 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
currentSongViewHolder.image.setImageResource(R.drawable.ic_volume_up_white_24dp);
|
currentSongViewHolder.image.setImageResource(R.drawable.ic_volume_up_white_24dp);
|
||||||
currentSongViewHolder.itemView.setOnClickListener(v -> {
|
currentSongViewHolder.itemView.setOnClickListener(v -> {
|
||||||
// toggle the panel
|
// toggle the panel
|
||||||
if (fragment.slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
if (binding.playerSlidingLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||||
fragment.slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
|
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
|
||||||
} else if (fragment.slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
} else if (binding.playerSlidingLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||||
fragment.slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
binding.playerSlidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -459,15 +431,15 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
public void setUpPanelAndAlbumCoverHeight() {
|
public void setUpPanelAndAlbumCoverHeight() {
|
||||||
WidthFitSquareLayout albumCoverContainer = fragment.getView().findViewById(R.id.album_cover_container);
|
WidthFitSquareLayout albumCoverContainer = fragment.getView().findViewById(R.id.album_cover_container);
|
||||||
|
|
||||||
final int availablePanelHeight = fragment.slidingUpPanelLayout.getHeight() - fragment.getView().findViewById(R.id.player_content).getHeight() + (int) ViewUtil.convertDpToPixel(8, fragment.getResources());
|
final int availablePanelHeight = binding.playerSlidingLayout.getHeight() - fragment.getView().findViewById(R.id.player_content).getHeight() + (int) ViewUtil.convertDpToPixel(8, fragment.getResources());
|
||||||
final int minPanelHeight = (int) ViewUtil.convertDpToPixel(72 + 24, fragment.getResources());
|
final int minPanelHeight = (int) ViewUtil.convertDpToPixel(72 + 24, fragment.getResources());
|
||||||
if (availablePanelHeight < minPanelHeight) {
|
if (availablePanelHeight < minPanelHeight) {
|
||||||
albumCoverContainer.getLayoutParams().height = albumCoverContainer.getHeight() - (minPanelHeight - availablePanelHeight);
|
albumCoverContainer.getLayoutParams().height = albumCoverContainer.getHeight() - (minPanelHeight - availablePanelHeight);
|
||||||
albumCoverContainer.forceSquare(false);
|
albumCoverContainer.forceSquare(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment.slidingUpPanelLayout.setPanelHeight(Math.max(minPanelHeight, availablePanelHeight));
|
binding.playerSlidingLayout.setPanelHeight(Math.max(minPanelHeight, availablePanelHeight));
|
||||||
((AbsSlidingMusicPanelActivity) fragment.getActivity()).setAntiDragView(fragment.slidingUpPanelLayout.findViewById(R.id.player_panel));
|
((AbsSlidingMusicPanelActivity) fragment.getActivity()).setAntiDragView(binding.playerSlidingLayout.findViewById(R.id.player_panel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -481,15 +453,15 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
public void animateColorChange(int newColor) {
|
public void animateColorChange(int newColor) {
|
||||||
super.animateColorChange(newColor);
|
super.animateColorChange(newColor);
|
||||||
|
|
||||||
fragment.slidingUpPanelLayout.setBackgroundColor(fragment.lastColor);
|
binding.playerSlidingLayout.setBackgroundColor(fragment.lastColor);
|
||||||
createDefaultColorChangeAnimatorSet(newColor).start();
|
createDefaultColorChangeAnimatorSet(newColor).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
private static class LandscapeImpl extends BaseImpl {
|
private static class LandscapeImpl extends BaseImpl {
|
||||||
public LandscapeImpl(CardPlayerFragment fragment) {
|
public LandscapeImpl(CardPlayerFragment fragment, FragmentCardPlayerBinding binding) {
|
||||||
super(fragment);
|
super(fragment, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -498,26 +470,26 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUpPanelAndAlbumCoverHeight() {
|
public void setUpPanelAndAlbumCoverHeight() {
|
||||||
int panelHeight = fragment.slidingUpPanelLayout.getHeight() - fragment.playbackControlsFragment.getView().getHeight();
|
int panelHeight = binding.playerSlidingLayout.getHeight() - fragment.playbackControlsFragment.getView().getHeight();
|
||||||
fragment.slidingUpPanelLayout.setPanelHeight(panelHeight);
|
binding.playerSlidingLayout.setPanelHeight(panelHeight);
|
||||||
|
|
||||||
((AbsSlidingMusicPanelActivity) fragment.getActivity()).setAntiDragView(fragment.slidingUpPanelLayout.findViewById(R.id.player_panel));
|
((AbsSlidingMusicPanelActivity) fragment.getActivity()).setAntiDragView(binding.playerSlidingLayout.findViewById(R.id.player_panel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCurrentSong(Song song) {
|
public void updateCurrentSong(Song song) {
|
||||||
fragment.toolbar.setTitle(song.title);
|
binding.playerToolbar.setTitle(song.title);
|
||||||
fragment.toolbar.setSubtitle(MusicUtil.getSongInfoString(song));
|
binding.playerToolbar.setSubtitle(MusicUtil.getSongInfoString(song));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void animateColorChange(int newColor) {
|
public void animateColorChange(int newColor) {
|
||||||
super.animateColorChange(newColor);
|
super.animateColorChange(newColor);
|
||||||
|
|
||||||
fragment.slidingUpPanelLayout.setBackgroundColor(fragment.lastColor);
|
binding.playerSlidingLayout.setBackgroundColor(fragment.lastColor);
|
||||||
|
|
||||||
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
|
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
|
||||||
animatorSet.play(ViewUtil.createBackgroundColorTransition(fragment.toolbar, fragment.lastColor, newColor))
|
animatorSet.play(ViewUtil.createBackgroundColorTransition(binding.playerToolbar, fragment.lastColor, newColor))
|
||||||
.with(ViewUtil.createBackgroundColorTransition(fragment.getView().findViewById(R.id.status_bar), ColorUtil.darkenColor(fragment.lastColor), ColorUtil.darkenColor(newColor)));
|
.with(ViewUtil.createBackgroundColorTransition(fragment.getView().findViewById(R.id.status_bar), ColorUtil.darkenColor(fragment.lastColor), ColorUtil.darkenColor(newColor)));
|
||||||
|
|
||||||
animatorSet.start();
|
animatorSet.start();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue