Skip to content
This repository was archived by the owner on Jul 22, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand Down
7 changes: 6 additions & 1 deletion library/src/main/java/link/fls/swipestack/SwipeStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class SwipeStack extends ViewGroup {
public static final float DEFAULT_SWIPE_OPACITY = 1f;
public static final float DEFAULT_SCALE_FACTOR = 1f;
public static final boolean DEFAULT_DISABLE_HW_ACCELERATION = true;
public static final boolean DEFAULT_STACK_ORDER_TOP = false;

private static final String KEY_SUPER_STATE = "superState";
private static final String KEY_CURRENT_INDEX = "currentIndex";
Expand All @@ -61,6 +62,7 @@ public class SwipeStack extends ViewGroup {
private float mSwipeOpacity;
private float mScaleFactor;
private boolean mDisableHwAcceleration;
private boolean mStackOrderTop;
private boolean mIsFirstLayout = true;

private View mTopView;
Expand Down Expand Up @@ -109,6 +111,9 @@ private void readAttributes(AttributeSet attributeSet) {
mDisableHwAcceleration =
attrs.getBoolean(R.styleable.SwipeStack_disable_hw_acceleration,
DEFAULT_DISABLE_HW_ACCELERATION);
mStackOrderTop =
attrs.getBoolean(R.styleable.SwipeStack_stack_order_top,
DEFAULT_STACK_ORDER_TOP);
} finally {
attrs.recycle();
}
Expand Down Expand Up @@ -222,7 +227,7 @@ private void reorderItems() {

int distanceToViewAbove = (topViewIndex * mViewSpacing) - (x * mViewSpacing);
int newPositionX = (getWidth() - childView.getMeasuredWidth()) / 2;
int newPositionY = distanceToViewAbove + getPaddingTop();
int newPositionY = mStackOrderTop ? -distanceToViewAbove + getPaddingTop() : distanceToViewAbove + getPaddingTop();

childView.layout(
newPositionX,
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<attr name="swipe_opacity" format="float"/>
<attr name="scale_factor" format="float"/>
<attr name="disable_hw_acceleration" format="boolean"/>
<attr name="stack_order_top" format="boolean" />
</declare-styleable>
</resources>
12 changes: 6 additions & 6 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -15,7 +14,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/swipe_left"/>
android:text="@string/swipe_left" />

<Button
android:id="@+id/buttonSwipeRight"
Expand All @@ -24,16 +23,17 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/swipe_right"/>
android:text="@string/swipe_right" />

<link.fls.swipestack.SwipeStack
android:id="@+id/swipeStack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonSwipeLeft"
android:padding="@dimen/padding_swipestack"
app:stack_order_top="true"
app:stack_rotation="10"
app:stack_size="3"/>
app:stack_size="3" />

<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
Expand All @@ -46,7 +46,7 @@
android:layout_gravity="bottom|center"
android:layout_margin="@dimen/margin_fab"
android:src="@drawable/ic_content_add"
app:fabSize="normal"/>
app:fabSize="normal" />

</android.support.design.widget.CoordinatorLayout>

Expand Down