diff --git a/build.gradle b/build.gradle index 6356aabd..21b3e999 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,13 @@ buildscript { repositories { jcenter() + maven { + url "https://jitpack.io" + } } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.github.dcendents:android-maven-plugin:1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,5 +19,8 @@ buildscript { allprojects { repositories { jcenter() + maven { + url "https://jitpack.io" + } } } diff --git a/library/build.gradle b/library/build.gradle index 3b815fe2..00c2f126 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -14,4 +14,14 @@ dependencies { compile 'com.android.support:recyclerview-v7:21.0.0' compile 'com.android.support:support-v4:22.1.1' } -apply from: './gradle-mvn-push.gradle' \ No newline at end of file +apply from: './gradle-mvn-push.gradle' + +apply plugin: 'android-maven' +// build a jar with source files +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} +artifacts { + archives sourcesJar +} diff --git a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java index d8ee9bde..b0f5f7c2 100644 --- a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java +++ b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java @@ -58,6 +58,7 @@ public class SwipeLayout extends FrameLayout { private boolean mSwipeEnabled = true; private boolean[] mSwipesEnabled = new boolean[]{true, true, true, true}; private boolean mClickToClose = false; + private AttributeSet attrs; public enum DragEdge { Left, @@ -81,15 +82,14 @@ public SwipeLayout(Context context, AttributeSet attrs) { public SwipeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + this.attrs = attrs; mDragHelper = ViewDragHelper.create(this, mDragHelperCallback); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout); + resetOffsets(); int dragEdgeChoices = a.getInt(R.styleable.SwipeLayout_drag_edge, DRAG_RIGHT); - mEdgeSwipesOffset[DragEdge.Left.ordinal()] = a.getDimension(R.styleable.SwipeLayout_leftEdgeSwipeOffset, 0); - mEdgeSwipesOffset[DragEdge.Right.ordinal()] = a.getDimension(R.styleable.SwipeLayout_rightEdgeSwipeOffset, 0); - mEdgeSwipesOffset[DragEdge.Top.ordinal()] = a.getDimension(R.styleable.SwipeLayout_topEdgeSwipeOffset, 0); - mEdgeSwipesOffset[DragEdge.Bottom.ordinal()] = a.getDimension(R.styleable.SwipeLayout_bottomEdgeSwipeOffset, 0); + setClickToClose(a.getBoolean(R.styleable.SwipeLayout_clickToClose, mClickToClose)); if ((dragEdgeChoices & DRAG_LEFT) == DRAG_LEFT) { @@ -110,6 +110,21 @@ public SwipeLayout(Context context, AttributeSet attrs, int defStyle) { } + /** + * Reset offsets of BottomView to prevent it scrolling across the screen when + * Certain versions of the close method are manually used. + * close(true, true) at the least. + */ + public void resetOffsets() { + TypedArray a = getContext() .obtainStyledAttributes(attrs, R.styleable.SwipeLayout); + + mEdgeSwipesOffset[DragEdge.Left.ordinal()] = a.getDimension(R.styleable.SwipeLayout_leftEdgeSwipeOffset, 0); + mEdgeSwipesOffset[DragEdge.Right.ordinal()] = a.getDimension(R.styleable.SwipeLayout_rightEdgeSwipeOffset, 0); + mEdgeSwipesOffset[DragEdge.Top.ordinal()] = a.getDimension(R.styleable.SwipeLayout_topEdgeSwipeOffset, 0); + mEdgeSwipesOffset[DragEdge.Bottom.ordinal()] = a.getDimension(R.styleable.SwipeLayout_bottomEdgeSwipeOffset, 0); + a.recycle(); + } + public interface SwipeListener { void onStartOpen(SwipeLayout layout);