[Android] Audio player: add shadows to the top and the bottom of the playlist

Adrien Maglo git at videolan.org
Fri Feb 7 14:09:50 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Feb  7 14:09:43 2014 +0100| [cf6d5036896cb3b02e4864be909810bc2e064d26] | committer: Adrien Maglo

Audio player: add shadows to the top and the bottom of the playlist

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=cf6d5036896cb3b02e4864be909810bc2e064d26
---

 vlc-android/res/drawable/audio_playlist_shadow.xml |   13 +++++++++++
 .../videolan/vlc/gui/audio/AudioPlaylistView.java  |   23 ++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/vlc-android/res/drawable/audio_playlist_shadow.xml b/vlc-android/res/drawable/audio_playlist_shadow.xml
new file mode 100644
index 0000000..463c34c
--- /dev/null
+++ b/vlc-android/res/drawable/audio_playlist_shadow.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <gradient
+        android:angle="90"
+        android:endColor="#00000000"
+        android:startColor="#a0a0a0" />
+
+    <size
+        android:height="5dp"
+        android:width="30dp" />
+
+</shape>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
index e84c428..53d3360 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -25,6 +25,7 @@ import org.videolan.vlc.R;
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -134,6 +135,28 @@ public class AudioPlaylistView extends ListView {
         }
     }
 
+    @Override
+    public void draw(Canvas c) {
+        super.draw(c);
+
+        // Draw the top and bottom list shadows.
+        Drawable mShadowDrawable = getResources().getDrawable(R.drawable.audio_playlist_shadow);
+
+        final int shadowHeight = mShadowDrawable.getIntrinsicHeight();
+        final int right = getRight();
+        final int left = getLeft();
+        final int bottom = getBottom();
+        final int top = bottom - shadowHeight;
+
+        mShadowDrawable.setBounds(left, top, right, bottom);
+        mShadowDrawable.draw(c);
+
+        c.rotate(180, c.getWidth() / 2, c.getHeight() / 2);
+
+        mShadowDrawable.setBounds(left, top, right, bottom);
+        mShadowDrawable.draw(c);
+    }
+
     public void startDrag(int positionDragStart, String title, String artist) {
         mPositionDragStart = positionDragStart;
         if (mDragShadow != null) {



More information about the Android mailing list