summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Huang <yabinh@google.com>2019-06-12 14:37:05 -0700
committerYabin Huang <yabinh@google.com>2019-06-18 17:49:55 -0700
commitfe29fedd19839650c94ecbe82add13f2dc0bfc50 (patch)
tree91a06a2868610537b241b7dcbdda3b5723870346
parent4c2a3239e61df4b94f103dc0c60025dd72d6b11b (diff)
downloadMedia-fe29fedd19839650c94ecbe82add13f2dc0bfc50.tar.gz
Adjust the position of playback queue list items
This CL adds an ItemDecoration above the first item of playback queue. As a result the normal list items are moved a bit downward when the queue is not scrolled. Fixes: 132653118 Test: manual Change-Id: Ie13626a592b216fce4390b3a65364e86814c722c
-rw-r--r--res/values/dimens.xml3
-rw-r--r--src/com/android/car/media/PlaybackFragment.java26
2 files changed, 29 insertions, 0 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 633d1b3..d3fb9d1 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -152,6 +152,9 @@
<dimen name="fragment_metadata_margin_x">@*android:dimen/car_margin</dimen>
<dimen name="playback_title_margin_end">@*android:dimen/car_padding_3</dimen>
+ <!-- PlaybackFragment.java -->
+ <dimen name="playback_queue_list_padding_top">@*android:dimen/car_padding_4</dimen>
+
<!-- queue_list_item.xml -->
<dimen name="queue_list_item_height">116dp</dimen>
<dimen name="queue_list_item_padding_x">@*android:dimen/car_keyline_1</dimen>
diff --git a/src/com/android/car/media/PlaybackFragment.java b/src/com/android/car/media/PlaybackFragment.java
index d869b5b..5b0dd56 100644
--- a/src/com/android/car/media/PlaybackFragment.java
+++ b/src/com/android/car/media/PlaybackFragment.java
@@ -19,6 +19,7 @@ package com.android.car.media;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
+import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@@ -215,6 +216,25 @@ public class PlaybackFragment extends Fragment {
}
}
+ private class QueueTopItemDecoration extends RecyclerView.ItemDecoration {
+ int mHeight;
+ int mDecorationPosition;
+
+ QueueTopItemDecoration(int height, int decorationPosition) {
+ mHeight = height;
+ mDecorationPosition = decorationPosition;
+ }
+
+ @Override
+ public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
+ RecyclerView.State state) {
+ super.getItemOffsets(outRect, view, parent, state);
+ if (parent.getChildAdapterPosition(view) == mDecorationPosition) {
+ outRect.top = mHeight;
+ }
+ }
+ }
+
@Override
public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
@@ -298,6 +318,12 @@ public class PlaybackFragment extends Fragment {
mPlaybackQueueBackgroundAlpha = getResources().getFloat(
R.dimen.playback_queue_background_alpha);
+ int decorationHeight = getResources().getDimensionPixelSize(
+ R.dimen.playback_queue_list_padding_top);
+ // Put the decoration above the first item.
+ int decorationPosition = 0;
+ mQueue.addItemDecoration(new QueueTopItemDecoration(decorationHeight, decorationPosition));
+
mQueue.setVerticalFadingEdgeEnabled(
getResources().getBoolean(R.bool.queue_fading_edge_length_enabled));
mQueueAdapter = new QueueItemsAdapter();