diff --git a/demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java b/demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java
index fd42733..bab1ee1 100644
--- a/demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java
+++ b/demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java
@@ -5,8 +5,8 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
diff --git a/demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java b/demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java
index 3b4c34d..d7061cd 100644
--- a/demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java
+++ b/demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java
@@ -1,7 +1,7 @@
package com.daimajia.swipedemo.adapter;
import android.content.Context;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
diff --git a/demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java b/demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java
index 85b5b3d..a33c740 100644
--- a/demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java
+++ b/demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java
@@ -5,8 +5,8 @@ import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@@ -122,4 +122,4 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
"DividerItemDecoration can only be used with a LinearLayoutManager.");
}
}
-}
\ No newline at end of file
+}
diff --git a/demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java b/demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java
index 613e8e5..dddf87b 100644
--- a/demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java
+++ b/demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java
@@ -1,7 +1,7 @@
package com.daimajia.swipedemo.adapter.util;
import android.content.Context;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
diff --git a/demo/src/main/res/layout/recyclerview.xml b/demo/src/main/res/layout/recyclerview.xml
index 3f1387f..8b1842b 100644
--- a/demo/src/main/res/layout/recyclerview.xml
+++ b/demo/src/main/res/layout/recyclerview.xml
@@ -1,7 +1,7 @@
-
\ No newline at end of file
+ android:scrollbars="vertical" />
diff --git a/library/build.gradle b/library/build.gradle
index 6b9631b..e6f4c40 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -11,9 +11,9 @@ android {
dependencies {
//noinspection GradleDependency,NewerVersionAvailable,GradleCompatible
- compile 'com.android.support:recyclerview-v7:25.2.0'
+ compile 'androidx.recyclerview:recyclerview:1.0.0'
//noinspection GradleDependency,NewerVersionAvailable,GradleCompatible
- compile 'com.android.support:support-v4:25.2.0'
+ compile 'androidx.legacy:legacy-support-v4:1.0.0'
}
apply from: './gradle-mvn-push.gradle'
diff --git a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java
index 25d09d5..69ddad1 100644
--- a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java
+++ b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java
@@ -3,9 +3,6 @@ package com.daimajia.swipe;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
-import android.support.v4.view.GravityCompat;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.Gravity;
@@ -27,6 +24,10 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import androidx.core.view.GravityCompat;
+import androidx.core.view.ViewCompat;
+import androidx.customview.widget.ViewDragHelper;
+
public class SwipeLayout extends FrameLayout {
@Deprecated
public static final int EMPTY_LAYOUT = -1;
@@ -143,7 +144,7 @@ public class SwipeLayout extends FrameLayout {
* Called in onInterceptTouchEvent Determines if this swipe event should
* be denied Implement this interface if you are using views with swipe
* gestures As a child of SwipeLayout
- *
+ *
* @return true deny false allow
*/
boolean shouldDenySwipe(MotionEvent ev);
@@ -182,8 +183,9 @@ public class SwipeLayout extends FrameLayout {
if (!mShowEntirely.containsKey(child)) {
mShowEntirely.put(child, false);
}
- if (mRevealListeners.get(child) == null)
+ if (mRevealListeners.get(child) == null) {
mRevealListeners.put(child, new ArrayList());
+ }
mRevealListeners.get(child).add(l);
}
@@ -196,17 +198,22 @@ public class SwipeLayout extends FrameLayout {
* @param l the {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
*/
public void addRevealListener(int[] childIds, OnRevealListener l) {
- for (int i : childIds)
+ for (int i : childIds) {
addRevealListener(i, l);
+ }
}
public void removeRevealListener(int childId, OnRevealListener l) {
View child = findViewById(childId);
- if (child == null) return;
+ if (child == null) {
+ return;
+ }
mShowEntirely.remove(child);
- if (mRevealListeners.containsKey(child)) mRevealListeners.get(child).remove(l);
+ if (mRevealListeners.containsKey(child)) {
+ mRevealListeners.get(child).remove(l);
+ }
}
public void removeAllRevealListeners(int childId) {
@@ -227,14 +234,20 @@ public class SwipeLayout extends FrameLayout {
case Bottom:
return getPaddingLeft();
case Left:
- if (left < getPaddingLeft()) return getPaddingLeft();
- if (left > getPaddingLeft() + mDragDistance)
+ if (left < getPaddingLeft()) {
+ return getPaddingLeft();
+ }
+ if (left > getPaddingLeft() + mDragDistance) {
return getPaddingLeft() + mDragDistance;
+ }
break;
case Right:
- if (left > getPaddingLeft()) return getPaddingLeft();
- if (left < getPaddingLeft() - mDragDistance)
+ if (left > getPaddingLeft()) {
+ return getPaddingLeft();
+ }
+ if (left < getPaddingLeft() - mDragDistance) {
return getPaddingLeft() - mDragDistance;
+ }
break;
}
} else if (getCurrentBottomView() == child) {
@@ -245,7 +258,9 @@ public class SwipeLayout extends FrameLayout {
return getPaddingLeft();
case Left:
if (mShowMode == ShowMode.PullOut) {
- if (left > getPaddingLeft()) return getPaddingLeft();
+ if (left > getPaddingLeft()) {
+ return getPaddingLeft();
+ }
}
break;
case Right:
@@ -268,9 +283,12 @@ public class SwipeLayout extends FrameLayout {
case Right:
return getPaddingTop();
case Top:
- if (top < getPaddingTop()) return getPaddingTop();
- if (top > getPaddingTop() + mDragDistance)
+ if (top < getPaddingTop()) {
+ return getPaddingTop();
+ }
+ if (top > getPaddingTop() + mDragDistance) {
return getPaddingTop() + mDragDistance;
+ }
break;
case Bottom:
if (top < getPaddingTop() - mDragDistance) {
@@ -289,23 +307,30 @@ public class SwipeLayout extends FrameLayout {
return getPaddingTop();
case Top:
if (mShowMode == ShowMode.PullOut) {
- if (top > getPaddingTop()) return getPaddingTop();
- } else {
- if (surfaceViewTop + dy < getPaddingTop())
+ if (top > getPaddingTop()) {
return getPaddingTop();
- if (surfaceViewTop + dy > getPaddingTop() + mDragDistance)
+ }
+ } else {
+ if (surfaceViewTop + dy < getPaddingTop()) {
+ return getPaddingTop();
+ }
+ if (surfaceViewTop + dy > getPaddingTop() + mDragDistance) {
return getPaddingTop() + mDragDistance;
+ }
}
break;
case Bottom:
if (mShowMode == ShowMode.PullOut) {
- if (top < getMeasuredHeight() - mDragDistance)
+ if (top < getMeasuredHeight() - mDragDistance) {
return getMeasuredHeight() - mDragDistance;
+ }
} else {
- if (surfaceViewTop + dy >= getPaddingTop())
+ if (surfaceViewTop + dy >= getPaddingTop()) {
return getPaddingTop();
- if (surfaceViewTop + dy <= getPaddingTop() - mDragDistance)
+ }
+ if (surfaceViewTop + dy <= getPaddingTop() - mDragDistance) {
return getPaddingTop() - mDragDistance;
+ }
}
}
}
@@ -347,7 +372,9 @@ public class SwipeLayout extends FrameLayout {
@Override
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
View surfaceView = getSurfaceView();
- if (surfaceView == null) return;
+ if (surfaceView == null) {
+ return;
+ }
View currentBottomView = getCurrentBottomView();
int evLeft = surfaceView.getLeft(),
evRight = surfaceView.getRight(),
@@ -376,14 +403,15 @@ public class SwipeLayout extends FrameLayout {
int newLeft = surfaceView.getLeft() + dx, newTop = surfaceView.getTop() + dy;
- if (mCurrentDragEdge == DragEdge.Left && newLeft < getPaddingLeft())
+ if (mCurrentDragEdge == DragEdge.Left && newLeft < getPaddingLeft()) {
newLeft = getPaddingLeft();
- else if (mCurrentDragEdge == DragEdge.Right && newLeft > getPaddingLeft())
+ } else if (mCurrentDragEdge == DragEdge.Right && newLeft > getPaddingLeft()) {
newLeft = getPaddingLeft();
- else if (mCurrentDragEdge == DragEdge.Top && newTop < getPaddingTop())
+ } else if (mCurrentDragEdge == DragEdge.Top && newTop < getPaddingTop()) {
newTop = getPaddingTop();
- else if (mCurrentDragEdge == DragEdge.Bottom && newTop > getPaddingTop())
+ } else if (mCurrentDragEdge == DragEdge.Bottom && newTop > getPaddingTop()) {
newTop = getPaddingTop();
+ }
surfaceView.layout(newLeft, newTop, newLeft + getMeasuredWidth(), newTop + getMeasuredHeight());
}
@@ -430,7 +458,9 @@ public class SwipeLayout extends FrameLayout {
*/
protected boolean isViewTotallyFirstShowed(View child, Rect relativePosition, DragEdge edge, int surfaceLeft,
int surfaceTop, int surfaceRight, int surfaceBottom) {
- if (mShowEntirely.get(child)) return false;
+ if (mShowEntirely.get(child)) {
+ return false;
+ }
int childLeft = relativePosition.left;
int childRight = relativePosition.right;
int childTop = relativePosition.top;
@@ -440,12 +470,16 @@ public class SwipeLayout extends FrameLayout {
if ((edge == DragEdge.Right && surfaceRight <= childLeft)
|| (edge == DragEdge.Left && surfaceLeft >= childRight)
|| (edge == DragEdge.Top && surfaceTop >= childBottom)
- || (edge == DragEdge.Bottom && surfaceBottom <= childTop)) r = true;
+ || (edge == DragEdge.Bottom && surfaceBottom <= childTop)) {
+ r = true;
+ }
} else if (getShowMode() == ShowMode.PullOut) {
if ((edge == DragEdge.Right && childRight <= getWidth())
|| (edge == DragEdge.Left && childLeft >= getPaddingLeft())
|| (edge == DragEdge.Top && childTop >= getPaddingTop())
- || (edge == DragEdge.Bottom && childBottom <= getHeight())) r = true;
+ || (edge == DragEdge.Bottom && childBottom <= getHeight())) {
+ r = true;
+ }
}
return r;
}
@@ -482,16 +516,24 @@ public class SwipeLayout extends FrameLayout {
} else if (getShowMode() == ShowMode.PullOut) {
switch (availableEdge) {
case Right:
- if (childLeft <= getWidth() && childRight > getWidth()) return true;
+ if (childLeft <= getWidth() && childRight > getWidth()) {
+ return true;
+ }
break;
case Left:
- if (childRight >= getPaddingLeft() && childLeft < getPaddingLeft()) return true;
+ if (childRight >= getPaddingLeft() && childLeft < getPaddingLeft()) {
+ return true;
+ }
break;
case Top:
- if (childTop < getPaddingTop() && childBottom >= getPaddingTop()) return true;
+ if (childTop < getPaddingTop() && childBottom >= getPaddingTop()) {
+ return true;
+ }
break;
case Bottom:
- if (childTop < getHeight() && childTop >= getPaddingTop()) return true;
+ if (childTop < getHeight() && childTop >= getPaddingTop()) {
+ return true;
+ }
break;
}
}
@@ -503,7 +545,9 @@ public class SwipeLayout extends FrameLayout {
Rect r = new Rect(t.getLeft(), t.getTop(), 0, 0);
while (t.getParent() != null && t != getRootView()) {
t = (View) t.getParent();
- if (t == this) break;
+ if (t == this) {
+ break;
+ }
r.left += t.getLeft();
r.top += t.getTop();
}
@@ -518,13 +562,21 @@ public class SwipeLayout extends FrameLayout {
DragEdge edge = getDragEdge();
boolean open = true;
if (edge == DragEdge.Left) {
- if (dx < 0) open = false;
+ if (dx < 0) {
+ open = false;
+ }
} else if (edge == DragEdge.Right) {
- if (dx > 0) open = false;
+ if (dx > 0) {
+ open = false;
+ }
} else if (edge == DragEdge.Top) {
- if (dy < 0) open = false;
+ if (dy < 0) {
+ open = false;
+ }
} else if (edge == DragEdge.Bottom) {
- if (dy > 0) open = false;
+ if (dy > 0) {
+ open = false;
+ }
}
dispatchSwipeEvent(surfaceLeft, surfaceTop, open);
@@ -590,7 +642,9 @@ public class SwipeLayout extends FrameLayout {
protected void dispatchRevealEvent(final int surfaceLeft, final int surfaceTop, final int surfaceRight,
final int surfaceBottom) {
- if (mRevealListeners.isEmpty()) return;
+ if (mRevealListeners.isEmpty()) {
+ return;
+ }
for (Map.Entry> entry : mRevealListeners.entrySet()) {
View child = entry.getKey();
Rect rect = getRelativePosition(child);
@@ -652,10 +706,11 @@ public class SwipeLayout extends FrameLayout {
mShowEntirely.put(child, true);
for (OnRevealListener l : entry.getValue()) {
if (mCurrentDragEdge == DragEdge.Left
- || mCurrentDragEdge == DragEdge.Right)
+ || mCurrentDragEdge == DragEdge.Right) {
l.onReveal(child, mCurrentDragEdge, 1, child.getWidth());
- else
+ } else {
l.onReveal(child, mCurrentDragEdge, 1, child.getHeight());
+ }
}
}
@@ -681,12 +736,16 @@ public class SwipeLayout extends FrameLayout {
private List mOnLayoutListeners;
public void addOnLayoutListener(OnLayout l) {
- if (mOnLayoutListeners == null) mOnLayoutListeners = new ArrayList();
+ if (mOnLayoutListeners == null) {
+ mOnLayoutListeners = new ArrayList();
+ }
mOnLayoutListeners.add(l);
}
public void removeOnLayoutListener(OnLayout l) {
- if (mOnLayoutListeners != null) mOnLayoutListeners.remove(l);
+ if (mOnLayoutListeners != null) {
+ mOnLayoutListeners.remove(l);
+ }
}
public void clearDragEdge() {
@@ -712,7 +771,9 @@ public class SwipeLayout extends FrameLayout {
}
public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutParams params) {
- if (child == null) return;
+ if (child == null) {
+ return;
+ }
if (params == null) {
params = generateDefaultLayoutParams();
@@ -743,7 +804,9 @@ public class SwipeLayout extends FrameLayout {
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
- if (child == null) return;
+ if (child == null) {
+ return;
+ }
int gravity = Gravity.NO_GRAVITY;
try {
gravity = (Integer) params.getClass().getField("gravity").get(params);
@@ -785,23 +848,28 @@ public class SwipeLayout extends FrameLayout {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
updateBottomViews();
- if (mOnLayoutListeners != null) for (int i = 0; i < mOnLayoutListeners.size(); i++) {
- mOnLayoutListeners.get(i).onLayout(this);
+ if (mOnLayoutListeners != null) {
+ for (int i = 0; i < mOnLayoutListeners.size(); i++) {
+ mOnLayoutListeners.get(i).onLayout(this);
+ }
}
}
void layoutPullOut() {
View surfaceView = getSurfaceView();
Rect surfaceRect = mViewBoundCache.get(surfaceView);
- if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
+ if (surfaceRect == null) {
+ surfaceRect = computeSurfaceLayoutArea(false);
+ }
if (surfaceView != null) {
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
bringChildToFront(surfaceView);
}
View currentBottomView = getCurrentBottomView();
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
- if (bottomViewRect == null)
+ if (bottomViewRect == null) {
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, surfaceRect);
+ }
if (currentBottomView != null) {
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
}
@@ -810,15 +878,18 @@ public class SwipeLayout extends FrameLayout {
void layoutLayDown() {
View surfaceView = getSurfaceView();
Rect surfaceRect = mViewBoundCache.get(surfaceView);
- if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
+ if (surfaceRect == null) {
+ surfaceRect = computeSurfaceLayoutArea(false);
+ }
if (surfaceView != null) {
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
bringChildToFront(surfaceView);
}
View currentBottomView = getCurrentBottomView();
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
- if (bottomViewRect == null)
+ if (bottomViewRect == null) {
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
+ }
if (currentBottomView != null) {
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
}
@@ -827,7 +898,9 @@ public class SwipeLayout extends FrameLayout {
private boolean mIsBeingDragged;
private void checkCanDrag(MotionEvent ev) {
- if (mIsBeingDragged) return;
+ if (mIsBeingDragged) {
+ return;
+ }
if (getOpenStatus() == Status.Middle) {
mIsBeingDragged = true;
return;
@@ -844,14 +917,18 @@ public class SwipeLayout extends FrameLayout {
dragEdge = DragEdge.Left;
} else if (distanceX < 0 && isRightSwipeEnabled()) {
dragEdge = DragEdge.Right;
- } else return;
+ } else {
+ return;
+ }
} else {
if (distanceY > 0 && isTopSwipeEnabled()) {
dragEdge = DragEdge.Top;
} else if (distanceY < 0 && isBottomSwipeEnabled()) {
dragEdge = DragEdge.Bottom;
- } else return;
+ } else {
+ return;
+ }
}
setCurrentDragEdge(dragEdge);
}
@@ -955,7 +1032,9 @@ public class SwipeLayout extends FrameLayout {
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (!isSwipeEnabled()) return super.onTouchEvent(event);
+ if (!isSwipeEnabled()) {
+ return super.onTouchEvent(event);
+ }
int action = event.getActionMasked();
gestureDetector.onTouchEvent(event);
@@ -1098,7 +1177,9 @@ public class SwipeLayout extends FrameLayout {
}
private void performAdapterViewItemClick() {
- if (getOpenStatus() != Status.Close) return;
+ if (getOpenStatus() != Status.Close) {
+ return;
+ }
ViewParent t = getParent();
if (t instanceof AdapterView) {
AdapterView view = (AdapterView) t;
@@ -1111,12 +1192,16 @@ public class SwipeLayout extends FrameLayout {
}
private boolean performAdapterViewItemLongClick() {
- if (getOpenStatus() != Status.Close) return false;
+ if (getOpenStatus() != Status.Close) {
+ return false;
+ }
ViewParent t = getParent();
if (t instanceof AdapterView) {
AdapterView view = (AdapterView) t;
int p = view.getPositionForView(SwipeLayout.this);
- if (p == AdapterView.INVALID_POSITION) return false;
+ if (p == AdapterView.INVALID_POSITION) {
+ return false;
+ }
long vId = view.getItemIdAtPosition(p);
boolean handled = false;
try {
@@ -1229,7 +1314,9 @@ public class SwipeLayout extends FrameLayout {
* @param max max distance in dp unit
*/
public void setDragDistance(int max) {
- if (max < 0) max = 0;
+ if (max < 0) {
+ max = 0;
+ }
mDragDistance = dp2px(max);
requestLayout();
}
@@ -1262,7 +1349,9 @@ public class SwipeLayout extends FrameLayout {
* return null if there is no surface view(no children)
*/
public View getSurfaceView() {
- if (getChildCount() == 0) return null;
+ if (getChildCount() == 0) {
+ return null;
+ }
return getChildAt(getChildCount() - 1);
}
@@ -1307,11 +1396,14 @@ public class SwipeLayout extends FrameLayout {
}
int surfaceLeft = surfaceView.getLeft();
int surfaceTop = surfaceView.getTop();
- if (surfaceLeft == getPaddingLeft() && surfaceTop == getPaddingTop() && !mIsBeingDragged) return Status.Close;
+ if (surfaceLeft == getPaddingLeft() && surfaceTop == getPaddingTop() && !mIsBeingDragged) {
+ return Status.Close;
+ }
if (surfaceLeft == (getPaddingLeft() - mDragDistance) || surfaceLeft == (getPaddingLeft() + mDragDistance)
- || surfaceTop == (getPaddingTop() - mDragDistance) || surfaceTop == (getPaddingTop() + mDragDistance))
+ || surfaceTop == (getPaddingTop() - mDragDistance) || surfaceTop == (getPaddingTop() + mDragDistance)) {
return Status.Open;
+ }
return Status.Middle;
}
@@ -1333,36 +1425,56 @@ public class SwipeLayout extends FrameLayout {
}
float willOpenPercent = (isCloseBeforeDragged ? mWillOpenPercentAfterClose : mWillOpenPercentAfterOpen);
if (currentDragEdge == DragEdge.Left) {
- if (xvel > minVelocity) open();
- else if (xvel < -minVelocity) close();
- else {
+ if (xvel > minVelocity) {
+ open();
+ } else if (xvel < -minVelocity) {
+ close();
+ } else {
float openPercent = 1f * getSurfaceView().getLeft() / mDragDistance;
- if (openPercent > willOpenPercent) open();
- else close();
+ if (openPercent > willOpenPercent) {
+ open();
+ } else {
+ close();
+ }
}
} else if (currentDragEdge == DragEdge.Right) {
- if (xvel > minVelocity) close();
- else if (xvel < -minVelocity) open();
- else {
+ if (xvel > minVelocity) {
+ close();
+ } else if (xvel < -minVelocity) {
+ open();
+ } else {
float openPercent = 1f * (-getSurfaceView().getLeft()) / mDragDistance;
- if (openPercent > willOpenPercent) open();
- else close();
+ if (openPercent > willOpenPercent) {
+ open();
+ } else {
+ close();
+ }
}
} else if (currentDragEdge == DragEdge.Top) {
- if (yvel > minVelocity) open();
- else if (yvel < -minVelocity) close();
- else {
+ if (yvel > minVelocity) {
+ open();
+ } else if (yvel < -minVelocity) {
+ close();
+ } else {
float openPercent = 1f * getSurfaceView().getTop() / mDragDistance;
- if (openPercent > willOpenPercent) open();
- else close();
+ if (openPercent > willOpenPercent) {
+ open();
+ } else {
+ close();
+ }
}
} else if (currentDragEdge == DragEdge.Bottom) {
- if (yvel > minVelocity) close();
- else if (yvel < -minVelocity) open();
- else {
+ if (yvel > minVelocity) {
+ close();
+ } else if (yvel < -minVelocity) {
+ open();
+ } else {
float openPercent = 1f * (-getSurfaceView().getTop()) / mDragDistance;
- if (openPercent > willOpenPercent) open();
- else close();
+ if (openPercent > willOpenPercent) {
+ open();
+ } else {
+ close();
+ }
}
}
}
@@ -1445,9 +1557,9 @@ public class SwipeLayout extends FrameLayout {
return;
}
int dx, dy;
- if (smooth)
+ if (smooth) {
mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(), getPaddingTop());
- else {
+ } else {
Rect rect = computeSurfaceLayoutArea(false);
dx = rect.left - surface.getLeft();
dy = rect.top - surface.getTop();
@@ -1467,9 +1579,11 @@ public class SwipeLayout extends FrameLayout {
}
public void toggle(boolean smooth) {
- if (getOpenStatus() == Status.Open)
+ if (getOpenStatus() == Status.Open) {
close(smooth);
- else if (getOpenStatus() == Status.Close) open(smooth);
+ } else if (getOpenStatus() == Status.Close) {
+ open(smooth);
+ }
}
@@ -1481,13 +1595,15 @@ public class SwipeLayout extends FrameLayout {
private Rect computeSurfaceLayoutArea(boolean open) {
int l = getPaddingLeft(), t = getPaddingTop();
if (open) {
- if (mCurrentDragEdge == DragEdge.Left)
+ if (mCurrentDragEdge == DragEdge.Left) {
l = getPaddingLeft() + mDragDistance;
- else if (mCurrentDragEdge == DragEdge.Right)
+ } else if (mCurrentDragEdge == DragEdge.Right) {
l = getPaddingLeft() - mDragDistance;
- else if (mCurrentDragEdge == DragEdge.Top)
+ } else if (mCurrentDragEdge == DragEdge.Top) {
t = getPaddingTop() + mDragDistance;
- else t = getPaddingTop() - mDragDistance;
+ } else {
+ t = getPaddingTop() - mDragDistance;
+ }
}
return new Rect(l, t, l + getMeasuredWidth(), t + getMeasuredHeight());
}
@@ -1498,13 +1614,15 @@ public class SwipeLayout extends FrameLayout {
int bl = rect.left, bt = rect.top, br = rect.right, bb = rect.bottom;
if (mode == ShowMode.PullOut) {
- if (mCurrentDragEdge == DragEdge.Left)
+ if (mCurrentDragEdge == DragEdge.Left) {
bl = rect.left - mDragDistance;
- else if (mCurrentDragEdge == DragEdge.Right)
+ } else if (mCurrentDragEdge == DragEdge.Right) {
bl = rect.right;
- else if (mCurrentDragEdge == DragEdge.Top)
+ } else if (mCurrentDragEdge == DragEdge.Top) {
bt = rect.top - mDragDistance;
- else bt = rect.bottom;
+ } else {
+ bt = rect.bottom;
+ }
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
bb = rect.bottom;
@@ -1514,13 +1632,15 @@ public class SwipeLayout extends FrameLayout {
br = rect.right;
}
} else if (mode == ShowMode.LayDown) {
- if (mCurrentDragEdge == DragEdge.Left)
+ if (mCurrentDragEdge == DragEdge.Left) {
br = bl + mDragDistance;
- else if (mCurrentDragEdge == DragEdge.Right)
+ } else if (mCurrentDragEdge == DragEdge.Right) {
bl = br - mDragDistance;
- else if (mCurrentDragEdge == DragEdge.Top)
+ } else if (mCurrentDragEdge == DragEdge.Top) {
bb = bt + mDragDistance;
- else bt = bb - mDragDistance;
+ } else {
+ bt = bb - mDragDistance;
+ }
}
return new Rect(bl, bt, br, bb);
@@ -1630,7 +1750,9 @@ public class SwipeLayout extends FrameLayout {
}
private float getCurrentOffset() {
- if (mCurrentDragEdge == null) return 0;
+ if (mCurrentDragEdge == null) {
+ return 0;
+ }
return mEdgeSwipesOffset[mCurrentDragEdge.ordinal()];
}
diff --git a/library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java b/library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java
index 3e6a62c..37f1dde 100644
--- a/library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java
+++ b/library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java
@@ -2,7 +2,6 @@ package com.daimajia.swipe.adapters;
import android.content.Context;
import android.database.Cursor;
-import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;
@@ -14,6 +13,8 @@ import com.daimajia.swipe.util.Attributes;
import java.util.List;
+import androidx.cursoradapter.widget.CursorAdapter;
+
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
diff --git a/library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java b/library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java
index f6e9aed..4e534ce 100644
--- a/library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java
+++ b/library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java
@@ -1,6 +1,6 @@
package com.daimajia.swipe.adapters;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.ViewGroup;
import com.daimajia.swipe.SwipeLayout;
diff --git a/library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java b/library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java
index 19b04ad..4f9c33d 100644
--- a/library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java
+++ b/library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java
@@ -2,7 +2,6 @@ package com.daimajia.swipe.adapters;
import android.content.Context;
import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.view.ViewGroup;
@@ -14,6 +13,8 @@ import com.daimajia.swipe.util.Attributes;
import java.util.List;
+import androidx.cursoradapter.widget.SimpleCursorAdapter;
+
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);