diff --git a/demo/build.gradle b/demo/build.gradle index 8aff86a..ae2fca1 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 20 - buildToolsVersion "20.0.0" + compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) + buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION defaultConfig { applicationId "com.daimajia.swipedemo" - minSdkVersion 8 - targetSdkVersion 20 - versionCode 1 - versionName "1.0" + minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) + targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) + versionName project.VERSION_NAME + versionCode Integer.parseInt(project.VERSION_CODE) } buildTypes { release { @@ -20,7 +20,6 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) compile project(":library") compile 'com.nineoldandroids:library:2.4.0' compile 'com.daimajia.easing:library:1.0.0@aar' diff --git a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java index 47b2d9c..ff7ab02 100644 --- a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java +++ b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java @@ -21,8 +21,8 @@ public class MyActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.main); - SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.godfather); - swipeLayout.setDragEdge(SwipeLayout.DragEdge.Bottom); +// SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.godfather); +// swipeLayout.setDragEdge(SwipeLayout.DragEdge.Bottom); // Set in XML //sample1 diff --git a/demo/src/main/res/layout/main.xml b/demo/src/main/res/layout/main.xml index 3376b82..759c1c9 100644 --- a/demo/src/main/res/layout/main.xml +++ b/demo/src/main/res/layout/main.xml @@ -1,8 +1,11 @@ - + android:layout_width="match_parent" android:layout_height="match_parent" + app:drag_edge="bottom"> - + diff --git a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java index bfa4aec..841958a 100644 --- a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java +++ b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java @@ -1,6 +1,7 @@ package com.daimajia.swipe; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Rect; import android.support.v4.view.ViewCompat; import android.support.v4.widget.ViewDragHelper; @@ -23,8 +24,8 @@ public class SwipeLayout extends FrameLayout { private ViewDragHelper mDragHelper; private int mDragDistance = 0; - private DragEdge mDragEdge = DragEdge.Right; - private ShowMode mShowMode = ShowMode.PullOut; + private DragEdge mDragEdge; + private ShowMode mShowMode; private List mSwipeListeners = new ArrayList(); private Map> mRevealListeners = new HashMap>(); @@ -53,6 +54,12 @@ public class SwipeLayout extends FrameLayout { public SwipeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mDragHelper = ViewDragHelper.create(this, mDragHelperCallback); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout); + int ordinal = a.getInt(R.styleable.SwipeLayout_drag_edge, DragEdge.Right.ordinal()); + mDragEdge = DragEdge.values()[ordinal]; + ordinal = a.getInt(R.styleable.SwipeLayout_show_mode, ShowMode.PullOut.ordinal()); + mShowMode = ShowMode.values()[ordinal]; } @@ -594,7 +601,7 @@ public class SwipeLayout extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - + if(mDragEdge == DragEdge.Left || mDragEdge == DragEdge.Right) mDragDistance = getBottomView().getMeasuredWidth(); else diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml new file mode 100644 index 0000000..c574ff7 --- /dev/null +++ b/library/src/main/res/values/attrs.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file