Commit d9883d41 authored by Adrien Maglo's avatar Adrien Maglo

SlidingPaneLayout: use a custom attribute to set the overhang size instead of...

SlidingPaneLayout: use a custom attribute to set the overhang size instead of using the minimum height of the slidable child

The new method is compatible with pre-16 APIs.
parent d70cfbb1
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<org.videolan.vlc.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android" <org.videolan.vlc.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:vlc="http://schemas.android.com/apk/res-auto"
android:id="@+id/pane" android:id="@+id/pane"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent"
vlc:overhangSize="60dp" >
<org.videolan.vlc.widget.ContentLinearLayout <org.videolan.vlc.widget.ContentLinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
...@@ -46,7 +48,6 @@ ...@@ -46,7 +48,6 @@
<FrameLayout <FrameLayout
android:id="@+id/audio_mini_player" android:id="@+id/audio_mini_player"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent" />
android:minHeight="60dp" />
</org.videolan.vlc.widget.SlidingPaneLayout> </org.videolan.vlc.widget.SlidingPaneLayout>
\ No newline at end of file
...@@ -12,4 +12,8 @@ ...@@ -12,4 +12,8 @@
<attr name="orange" format="reference|color" /> <attr name="orange" format="reference|color" />
<attr name="darkorange" format="reference|color" /> <attr name="darkorange" format="reference|color" />
<declare-styleable name="SlidingPaneLayout">
<attr name="overhangSize" format="dimension" />
</declare-styleable>
</resources> </resources>
\ No newline at end of file
...@@ -24,6 +24,7 @@ package org.videolan.vlc.widget; ...@@ -24,6 +24,7 @@ package org.videolan.vlc.widget;
*/ */
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.Rect; import android.graphics.Rect;
...@@ -48,6 +49,8 @@ import java.lang.reflect.Field; ...@@ -48,6 +49,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import org.videolan.vlc.R;
public class SlidingPaneLayout extends ViewGroup { public class SlidingPaneLayout extends ViewGroup {
private static final String TAG = "VLC/SlidingPaneLayout"; private static final String TAG = "VLC/SlidingPaneLayout";
...@@ -151,8 +154,20 @@ public class SlidingPaneLayout extends ViewGroup { ...@@ -151,8 +154,20 @@ public class SlidingPaneLayout extends ViewGroup {
public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) { public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
mOverhangSize = -1;
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingPaneLayout);
if (ta != null)
mOverhangSize = ta.getDimensionPixelSize(R.styleable.SlidingPaneLayout_overhangSize, -1);
ta.recycle();
}
final float density = context.getResources().getDisplayMetrics().density; final float density = context.getResources().getDisplayMetrics().density;
mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f); if (mOverhangSize == -1) {
mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f);
}
setWillNotDraw(false); setWillNotDraw(false);
...@@ -402,10 +417,6 @@ public class SlidingPaneLayout extends ViewGroup { ...@@ -402,10 +417,6 @@ public class SlidingPaneLayout extends ViewGroup {
int offset = 0; int offset = 0;
if (lp.slideable) { if (lp.slideable) {
int overhangSize = child.getMinimumHeight();
if (overhangSize != 0)
mOverhangSize = overhangSize;
final int margin = lp.topMargin + lp.bottomMargin; final int margin = lp.topMargin + lp.bottomMargin;
final int range = Math.min(nextYStart, height - paddingBottom) - yStart - margin; final int range = Math.min(nextYStart, height - paddingBottom) - yStart - margin;
mSlideRange = range; mSlideRange = range;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment