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 27ba09d..9cbbcde 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]; } @@ -590,7 +597,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/drawable-hdpi/ic_launcher.png b/library/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 96a442e..0000000 Binary files a/library/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/library/src/main/res/drawable-mdpi/ic_launcher.png b/library/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 359047d..0000000 Binary files a/library/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/library/src/main/res/drawable-xhdpi/ic_launcher.png b/library/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 71c6d76..0000000 Binary files a/library/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/library/src/main/res/drawable-xxhdpi/ic_launcher.png b/library/src/main/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 4df1894..0000000 Binary files a/library/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ 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 diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml deleted file mode 100644 index 49fc91e..0000000 --- a/library/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - library -