Added landscape version for the flat player.
This commit is contained in:
parent
aaef21f455
commit
29167124df
3 changed files with 160 additions and 8 deletions
|
|
@ -451,7 +451,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
public AnimatorSet createDefaultColorChangeAnimatorSet(CardPlayerFragment fragment, int newColor) {
|
||||
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
|
||||
Animator backgroundAnimator;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
int topMargin = fragment.getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||
|
|
@ -572,7 +572,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
|
||||
fragment.slidingUpPanelLayout.setBackgroundColor(fragment.lastColor);
|
||||
|
||||
createDefaultColorChangeAnimatorSet(fragment, newColor).start();
|
||||
createDefaultColorChangeAnimatorSet(newColor).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -608,7 +608,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
|
||||
fragment.slidingUpPanelLayout.setBackgroundColor(fragment.lastColor);
|
||||
|
||||
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(fragment, newColor);
|
||||
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
|
||||
animatorSet.play(ViewUtil.createBackgroundColorTransition(fragment.toolbar, fragment.lastColor, newColor))
|
||||
.with(ViewUtil.createBackgroundColorTransition(fragment.getView().findViewById(R.id.status_bar), ColorUtil.darkenColor(fragment.lastColor), ColorUtil.darkenColor(newColor)));
|
||||
animatorSet.start();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
|
@ -63,6 +64,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
View playerStatusBar;
|
||||
@Bind(R.id.player_toolbar)
|
||||
Toolbar toolbar;
|
||||
@Nullable
|
||||
@Bind(R.id.player_sliding_layout)
|
||||
SlidingUpPanelLayout slidingUpPanelLayout;
|
||||
@Bind(R.id.player_recycler_view)
|
||||
|
|
@ -91,7 +93,11 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (Util.isLandscape(getResources())) {
|
||||
impl = new LandscapeImpl(this);
|
||||
} else {
|
||||
impl = new PortraitImpl(this);
|
||||
}
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_flat_player, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
|
|
@ -109,8 +115,10 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
|
||||
setUpRecyclerView();
|
||||
|
||||
if (slidingUpPanelLayout != null) {
|
||||
slidingUpPanelLayout.addPanelSlideListener(this);
|
||||
slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));
|
||||
}
|
||||
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
|
@ -183,14 +191,14 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
|
||||
private void updateQueue() {
|
||||
playingQueueAdapter.swapDataSet(MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition());
|
||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||
if (slidingUpPanelLayout == null || slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||
resetToCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateQueuePosition() {
|
||||
playingQueueAdapter.setCurrent(MusicPlayerRemote.getPosition());
|
||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||
if (slidingUpPanelLayout == null || slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
|
||||
resetToCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
|
@ -403,6 +411,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
onPanelCollapsed(panel);
|
||||
break;
|
||||
case ANCHORED:
|
||||
//noinspection ConstantConditions
|
||||
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); // this fixes a bug where the panel would get stuck for some reason
|
||||
break;
|
||||
}
|
||||
|
|
@ -542,4 +551,35 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
createDefaultColorChangeAnimatorSet(newColor).start();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private static class LandscapeImpl extends BaseImpl {
|
||||
public LandscapeImpl(FlatPlayerFragment fragment) {
|
||||
super(fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpPanelAndAlbumCoverHeight() {
|
||||
((AbsSlidingMusicPanelActivity) fragment.getActivity()).setAntiDragView(fragment.getView().findViewById(R.id.player_panel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCurrentSong(Song song) {
|
||||
fragment.toolbar.setTitle(song.title);
|
||||
fragment.toolbar.setSubtitle(song.artistName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateColorChange(int newColor) {
|
||||
super.animateColorChange(newColor);
|
||||
|
||||
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(newColor);
|
||||
animatorSet.play(ViewUtil.createBackgroundColorTransition(fragment.toolbar, fragment.lastColor, newColor));
|
||||
animatorSet.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
112
app/src/main/res/layout-land/fragment_flat_player.xml
Normal file
112
app/src/main/res/layout-land/fragment_flat_player.xml
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="@dimen/toolbar_elevation"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<View
|
||||
android:id="@+id/player_status_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/status_bar_padding" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/status_bar_padding"
|
||||
android:background="@color/twenty_percent_black_overlay" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/player_toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.kabouzeid.gramophone.views.HeightFitSquareLayout
|
||||
android:id="@+id/cover_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/player_album_cover_fragment"
|
||||
class="com.kabouzeid.gramophone.ui.fragments.player.PlayerAlbumCoverFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</com.kabouzeid.gramophone.views.HeightFitSquareLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toEndOf="@+id/cover_container"
|
||||
android:layout_toRightOf="@+id/cover_container"
|
||||
android:orientation="vertical">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playback_controls_fragment"
|
||||
class="com.kabouzeid.gramophone.ui.fragments.player.flat.FlatPlayerPlaybackControlsFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/player_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!--This is necessary for the drag sorting to work at the top-->
|
||||
<View
|
||||
android:id="@+id/draggable_area"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/player_panel_content"
|
||||
android:layout_alignTop="@+id/player_panel_content"
|
||||
android:layout_marginTop="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/player_panel_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:background="@drawable/shadow_down" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/player_queue_sub_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/up_next"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="?android:textColorSecondary" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/player_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:requiresFadingEdge="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue