Compare commits
6 Commits
master
...
feature/an
| Author | SHA1 | Date |
|---|---|---|
|
|
04974c2d8c | |
|
|
4e759e384d | |
|
|
368497fe36 | |
|
|
f2955e48fc | |
|
|
90428bb951 | |
|
|
998158635f |
|
|
@ -8,8 +8,8 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.3.0'
|
// classpath 'com.android.tools.build:gradle:2.3.0'
|
||||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
// classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.daimajia.swipedemo.adapter;
|
package com.daimajia.swipedemo.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
|
@ -122,4 +122,4 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||||
"DividerItemDecoration can only be used with a LinearLayoutManager.");
|
"DividerItemDecoration can only be used with a LinearLayoutManager.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.daimajia.swipedemo.adapter.util;
|
package com.daimajia.swipedemo.adapter.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- A RecyclerView with some commonly used attributes -->
|
<!-- A RecyclerView with some commonly used attributes -->
|
||||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scrollbars="vertical" />
|
android:scrollbars="vertical" />
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
|
|
@ -11,8 +10,8 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:recyclerview-v7:25.2.0'
|
compile "androidx.recyclerview:recyclerview:$androidx"
|
||||||
compile 'com.android.support:support-v4:25.2.0'
|
compile 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
}
|
}
|
||||||
apply from: './gradle-mvn-push.gradle'
|
apply from: './gradle-mvn-push.gradle'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ package com.daimajia.swipe;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Rect;
|
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.util.AttributeSet;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
|
@ -27,6 +24,10 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import androidx.core.view.GravityCompat;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.customview.widget.ViewDragHelper;
|
||||||
|
|
||||||
public class SwipeLayout extends FrameLayout {
|
public class SwipeLayout extends FrameLayout {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int EMPTY_LAYOUT = -1;
|
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
|
* Called in onInterceptTouchEvent Determines if this swipe event should
|
||||||
* be denied Implement this interface if you are using views with swipe
|
* be denied Implement this interface if you are using views with swipe
|
||||||
* gestures As a child of SwipeLayout
|
* gestures As a child of SwipeLayout
|
||||||
*
|
*
|
||||||
* @return true deny false allow
|
* @return true deny false allow
|
||||||
*/
|
*/
|
||||||
boolean shouldDenySwipe(MotionEvent ev);
|
boolean shouldDenySwipe(MotionEvent ev);
|
||||||
|
|
@ -182,8 +183,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
if (!mShowEntirely.containsKey(child)) {
|
if (!mShowEntirely.containsKey(child)) {
|
||||||
mShowEntirely.put(child, false);
|
mShowEntirely.put(child, false);
|
||||||
}
|
}
|
||||||
if (mRevealListeners.get(child) == null)
|
if (mRevealListeners.get(child) == null) {
|
||||||
mRevealListeners.put(child, new ArrayList<OnRevealListener>());
|
mRevealListeners.put(child, new ArrayList<OnRevealListener>());
|
||||||
|
}
|
||||||
|
|
||||||
mRevealListeners.get(child).add(l);
|
mRevealListeners.get(child).add(l);
|
||||||
}
|
}
|
||||||
|
|
@ -196,17 +198,22 @@ public class SwipeLayout extends FrameLayout {
|
||||||
* @param l the {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
|
* @param l the {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
|
||||||
*/
|
*/
|
||||||
public void addRevealListener(int[] childIds, OnRevealListener l) {
|
public void addRevealListener(int[] childIds, OnRevealListener l) {
|
||||||
for (int i : childIds)
|
for (int i : childIds) {
|
||||||
addRevealListener(i, l);
|
addRevealListener(i, l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRevealListener(int childId, OnRevealListener l) {
|
public void removeRevealListener(int childId, OnRevealListener l) {
|
||||||
View child = findViewById(childId);
|
View child = findViewById(childId);
|
||||||
|
|
||||||
if (child == null) return;
|
if (child == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mShowEntirely.remove(child);
|
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) {
|
public void removeAllRevealListeners(int childId) {
|
||||||
|
|
@ -227,14 +234,20 @@ public class SwipeLayout extends FrameLayout {
|
||||||
case Bottom:
|
case Bottom:
|
||||||
return getPaddingLeft();
|
return getPaddingLeft();
|
||||||
case Left:
|
case Left:
|
||||||
if (left < getPaddingLeft()) return getPaddingLeft();
|
if (left < getPaddingLeft()) {
|
||||||
if (left > getPaddingLeft() + mDragDistance)
|
return getPaddingLeft();
|
||||||
|
}
|
||||||
|
if (left > getPaddingLeft() + mDragDistance) {
|
||||||
return getPaddingLeft() + mDragDistance;
|
return getPaddingLeft() + mDragDistance;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
if (left > getPaddingLeft()) return getPaddingLeft();
|
if (left > getPaddingLeft()) {
|
||||||
if (left < getPaddingLeft() - mDragDistance)
|
return getPaddingLeft();
|
||||||
|
}
|
||||||
|
if (left < getPaddingLeft() - mDragDistance) {
|
||||||
return getPaddingLeft() - mDragDistance;
|
return getPaddingLeft() - mDragDistance;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (getCurrentBottomView() == child) {
|
} else if (getCurrentBottomView() == child) {
|
||||||
|
|
@ -245,7 +258,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
return getPaddingLeft();
|
return getPaddingLeft();
|
||||||
case Left:
|
case Left:
|
||||||
if (mShowMode == ShowMode.PullOut) {
|
if (mShowMode == ShowMode.PullOut) {
|
||||||
if (left > getPaddingLeft()) return getPaddingLeft();
|
if (left > getPaddingLeft()) {
|
||||||
|
return getPaddingLeft();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
|
|
@ -268,9 +283,12 @@ public class SwipeLayout extends FrameLayout {
|
||||||
case Right:
|
case Right:
|
||||||
return getPaddingTop();
|
return getPaddingTop();
|
||||||
case Top:
|
case Top:
|
||||||
if (top < getPaddingTop()) return getPaddingTop();
|
if (top < getPaddingTop()) {
|
||||||
if (top > getPaddingTop() + mDragDistance)
|
return getPaddingTop();
|
||||||
|
}
|
||||||
|
if (top > getPaddingTop() + mDragDistance) {
|
||||||
return getPaddingTop() + mDragDistance;
|
return getPaddingTop() + mDragDistance;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if (top < getPaddingTop() - mDragDistance) {
|
if (top < getPaddingTop() - mDragDistance) {
|
||||||
|
|
@ -289,23 +307,30 @@ public class SwipeLayout extends FrameLayout {
|
||||||
return getPaddingTop();
|
return getPaddingTop();
|
||||||
case Top:
|
case Top:
|
||||||
if (mShowMode == ShowMode.PullOut) {
|
if (mShowMode == ShowMode.PullOut) {
|
||||||
if (top > getPaddingTop()) return getPaddingTop();
|
if (top > getPaddingTop()) {
|
||||||
} else {
|
|
||||||
if (surfaceViewTop + dy < getPaddingTop())
|
|
||||||
return getPaddingTop();
|
return getPaddingTop();
|
||||||
if (surfaceViewTop + dy > getPaddingTop() + mDragDistance)
|
}
|
||||||
|
} else {
|
||||||
|
if (surfaceViewTop + dy < getPaddingTop()) {
|
||||||
|
return getPaddingTop();
|
||||||
|
}
|
||||||
|
if (surfaceViewTop + dy > getPaddingTop() + mDragDistance) {
|
||||||
return getPaddingTop() + mDragDistance;
|
return getPaddingTop() + mDragDistance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if (mShowMode == ShowMode.PullOut) {
|
if (mShowMode == ShowMode.PullOut) {
|
||||||
if (top < getMeasuredHeight() - mDragDistance)
|
if (top < getMeasuredHeight() - mDragDistance) {
|
||||||
return getMeasuredHeight() - mDragDistance;
|
return getMeasuredHeight() - mDragDistance;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (surfaceViewTop + dy >= getPaddingTop())
|
if (surfaceViewTop + dy >= getPaddingTop()) {
|
||||||
return getPaddingTop();
|
return getPaddingTop();
|
||||||
if (surfaceViewTop + dy <= getPaddingTop() - mDragDistance)
|
}
|
||||||
|
if (surfaceViewTop + dy <= getPaddingTop() - mDragDistance) {
|
||||||
return getPaddingTop() - mDragDistance;
|
return getPaddingTop() - mDragDistance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +372,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
@Override
|
@Override
|
||||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||||
View surfaceView = getSurfaceView();
|
View surfaceView = getSurfaceView();
|
||||||
if (surfaceView == null) return;
|
if (surfaceView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
View currentBottomView = getCurrentBottomView();
|
View currentBottomView = getCurrentBottomView();
|
||||||
int evLeft = surfaceView.getLeft(),
|
int evLeft = surfaceView.getLeft(),
|
||||||
evRight = surfaceView.getRight(),
|
evRight = surfaceView.getRight(),
|
||||||
|
|
@ -376,14 +403,15 @@ public class SwipeLayout extends FrameLayout {
|
||||||
|
|
||||||
int newLeft = surfaceView.getLeft() + dx, newTop = surfaceView.getTop() + dy;
|
int newLeft = surfaceView.getLeft() + dx, newTop = surfaceView.getTop() + dy;
|
||||||
|
|
||||||
if (mCurrentDragEdge == DragEdge.Left && newLeft < getPaddingLeft())
|
if (mCurrentDragEdge == DragEdge.Left && newLeft < getPaddingLeft()) {
|
||||||
newLeft = getPaddingLeft();
|
newLeft = getPaddingLeft();
|
||||||
else if (mCurrentDragEdge == DragEdge.Right && newLeft > getPaddingLeft())
|
} else if (mCurrentDragEdge == DragEdge.Right && newLeft > getPaddingLeft()) {
|
||||||
newLeft = getPaddingLeft();
|
newLeft = getPaddingLeft();
|
||||||
else if (mCurrentDragEdge == DragEdge.Top && newTop < getPaddingTop())
|
} else if (mCurrentDragEdge == DragEdge.Top && newTop < getPaddingTop()) {
|
||||||
newTop = getPaddingTop();
|
newTop = getPaddingTop();
|
||||||
else if (mCurrentDragEdge == DragEdge.Bottom && newTop > getPaddingTop())
|
} else if (mCurrentDragEdge == DragEdge.Bottom && newTop > getPaddingTop()) {
|
||||||
newTop = getPaddingTop();
|
newTop = getPaddingTop();
|
||||||
|
}
|
||||||
|
|
||||||
surfaceView.layout(newLeft, newTop, newLeft + getMeasuredWidth(), newTop + getMeasuredHeight());
|
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,
|
protected boolean isViewTotallyFirstShowed(View child, Rect relativePosition, DragEdge edge, int surfaceLeft,
|
||||||
int surfaceTop, int surfaceRight, int surfaceBottom) {
|
int surfaceTop, int surfaceRight, int surfaceBottom) {
|
||||||
if (mShowEntirely.get(child)) return false;
|
if (mShowEntirely.get(child)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int childLeft = relativePosition.left;
|
int childLeft = relativePosition.left;
|
||||||
int childRight = relativePosition.right;
|
int childRight = relativePosition.right;
|
||||||
int childTop = relativePosition.top;
|
int childTop = relativePosition.top;
|
||||||
|
|
@ -440,12 +470,16 @@ public class SwipeLayout extends FrameLayout {
|
||||||
if ((edge == DragEdge.Right && surfaceRight <= childLeft)
|
if ((edge == DragEdge.Right && surfaceRight <= childLeft)
|
||||||
|| (edge == DragEdge.Left && surfaceLeft >= childRight)
|
|| (edge == DragEdge.Left && surfaceLeft >= childRight)
|
||||||
|| (edge == DragEdge.Top && surfaceTop >= childBottom)
|
|| (edge == DragEdge.Top && surfaceTop >= childBottom)
|
||||||
|| (edge == DragEdge.Bottom && surfaceBottom <= childTop)) r = true;
|
|| (edge == DragEdge.Bottom && surfaceBottom <= childTop)) {
|
||||||
|
r = true;
|
||||||
|
}
|
||||||
} else if (getShowMode() == ShowMode.PullOut) {
|
} else if (getShowMode() == ShowMode.PullOut) {
|
||||||
if ((edge == DragEdge.Right && childRight <= getWidth())
|
if ((edge == DragEdge.Right && childRight <= getWidth())
|
||||||
|| (edge == DragEdge.Left && childLeft >= getPaddingLeft())
|
|| (edge == DragEdge.Left && childLeft >= getPaddingLeft())
|
||||||
|| (edge == DragEdge.Top && childTop >= getPaddingTop())
|
|| (edge == DragEdge.Top && childTop >= getPaddingTop())
|
||||||
|| (edge == DragEdge.Bottom && childBottom <= getHeight())) r = true;
|
|| (edge == DragEdge.Bottom && childBottom <= getHeight())) {
|
||||||
|
r = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
@ -482,16 +516,24 @@ public class SwipeLayout extends FrameLayout {
|
||||||
} else if (getShowMode() == ShowMode.PullOut) {
|
} else if (getShowMode() == ShowMode.PullOut) {
|
||||||
switch (availableEdge) {
|
switch (availableEdge) {
|
||||||
case Right:
|
case Right:
|
||||||
if (childLeft <= getWidth() && childRight > getWidth()) return true;
|
if (childLeft <= getWidth() && childRight > getWidth()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
if (childRight >= getPaddingLeft() && childLeft < getPaddingLeft()) return true;
|
if (childRight >= getPaddingLeft() && childLeft < getPaddingLeft()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Top:
|
case Top:
|
||||||
if (childTop < getPaddingTop() && childBottom >= getPaddingTop()) return true;
|
if (childTop < getPaddingTop() && childBottom >= getPaddingTop()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if (childTop < getHeight() && childTop >= getPaddingTop()) return true;
|
if (childTop < getHeight() && childTop >= getPaddingTop()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +545,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
Rect r = new Rect(t.getLeft(), t.getTop(), 0, 0);
|
Rect r = new Rect(t.getLeft(), t.getTop(), 0, 0);
|
||||||
while (t.getParent() != null && t != getRootView()) {
|
while (t.getParent() != null && t != getRootView()) {
|
||||||
t = (View) t.getParent();
|
t = (View) t.getParent();
|
||||||
if (t == this) break;
|
if (t == this) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
r.left += t.getLeft();
|
r.left += t.getLeft();
|
||||||
r.top += t.getTop();
|
r.top += t.getTop();
|
||||||
}
|
}
|
||||||
|
|
@ -518,13 +562,21 @@ public class SwipeLayout extends FrameLayout {
|
||||||
DragEdge edge = getDragEdge();
|
DragEdge edge = getDragEdge();
|
||||||
boolean open = true;
|
boolean open = true;
|
||||||
if (edge == DragEdge.Left) {
|
if (edge == DragEdge.Left) {
|
||||||
if (dx < 0) open = false;
|
if (dx < 0) {
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
} else if (edge == DragEdge.Right) {
|
} else if (edge == DragEdge.Right) {
|
||||||
if (dx > 0) open = false;
|
if (dx > 0) {
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
} else if (edge == DragEdge.Top) {
|
} else if (edge == DragEdge.Top) {
|
||||||
if (dy < 0) open = false;
|
if (dy < 0) {
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
} else if (edge == DragEdge.Bottom) {
|
} else if (edge == DragEdge.Bottom) {
|
||||||
if (dy > 0) open = false;
|
if (dy > 0) {
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchSwipeEvent(surfaceLeft, surfaceTop, open);
|
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,
|
protected void dispatchRevealEvent(final int surfaceLeft, final int surfaceTop, final int surfaceRight,
|
||||||
final int surfaceBottom) {
|
final int surfaceBottom) {
|
||||||
if (mRevealListeners.isEmpty()) return;
|
if (mRevealListeners.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (Map.Entry<View, ArrayList<OnRevealListener>> entry : mRevealListeners.entrySet()) {
|
for (Map.Entry<View, ArrayList<OnRevealListener>> entry : mRevealListeners.entrySet()) {
|
||||||
View child = entry.getKey();
|
View child = entry.getKey();
|
||||||
Rect rect = getRelativePosition(child);
|
Rect rect = getRelativePosition(child);
|
||||||
|
|
@ -652,10 +706,11 @@ public class SwipeLayout extends FrameLayout {
|
||||||
mShowEntirely.put(child, true);
|
mShowEntirely.put(child, true);
|
||||||
for (OnRevealListener l : entry.getValue()) {
|
for (OnRevealListener l : entry.getValue()) {
|
||||||
if (mCurrentDragEdge == DragEdge.Left
|
if (mCurrentDragEdge == DragEdge.Left
|
||||||
|| mCurrentDragEdge == DragEdge.Right)
|
|| mCurrentDragEdge == DragEdge.Right) {
|
||||||
l.onReveal(child, mCurrentDragEdge, 1, child.getWidth());
|
l.onReveal(child, mCurrentDragEdge, 1, child.getWidth());
|
||||||
else
|
} else {
|
||||||
l.onReveal(child, mCurrentDragEdge, 1, child.getHeight());
|
l.onReveal(child, mCurrentDragEdge, 1, child.getHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -681,12 +736,16 @@ public class SwipeLayout extends FrameLayout {
|
||||||
private List<OnLayout> mOnLayoutListeners;
|
private List<OnLayout> mOnLayoutListeners;
|
||||||
|
|
||||||
public void addOnLayoutListener(OnLayout l) {
|
public void addOnLayoutListener(OnLayout l) {
|
||||||
if (mOnLayoutListeners == null) mOnLayoutListeners = new ArrayList<OnLayout>();
|
if (mOnLayoutListeners == null) {
|
||||||
|
mOnLayoutListeners = new ArrayList<OnLayout>();
|
||||||
|
}
|
||||||
mOnLayoutListeners.add(l);
|
mOnLayoutListeners.add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeOnLayoutListener(OnLayout l) {
|
public void removeOnLayoutListener(OnLayout l) {
|
||||||
if (mOnLayoutListeners != null) mOnLayoutListeners.remove(l);
|
if (mOnLayoutListeners != null) {
|
||||||
|
mOnLayoutListeners.remove(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearDragEdge() {
|
public void clearDragEdge() {
|
||||||
|
|
@ -712,7 +771,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutParams params) {
|
public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutParams params) {
|
||||||
if (child == null) return;
|
if (child == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = generateDefaultLayoutParams();
|
params = generateDefaultLayoutParams();
|
||||||
|
|
@ -743,7 +804,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
||||||
if (child == null) return;
|
if (child == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int gravity = Gravity.NO_GRAVITY;
|
int gravity = Gravity.NO_GRAVITY;
|
||||||
try {
|
try {
|
||||||
gravity = (Integer) params.getClass().getField("gravity").get(params);
|
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) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
updateBottomViews();
|
updateBottomViews();
|
||||||
|
|
||||||
if (mOnLayoutListeners != null) for (int i = 0; i < mOnLayoutListeners.size(); i++) {
|
if (mOnLayoutListeners != null) {
|
||||||
mOnLayoutListeners.get(i).onLayout(this);
|
for (int i = 0; i < mOnLayoutListeners.size(); i++) {
|
||||||
|
mOnLayoutListeners.get(i).onLayout(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void layoutPullOut() {
|
void layoutPullOut() {
|
||||||
View surfaceView = getSurfaceView();
|
View surfaceView = getSurfaceView();
|
||||||
Rect surfaceRect = mViewBoundCache.get(surfaceView);
|
Rect surfaceRect = mViewBoundCache.get(surfaceView);
|
||||||
if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
|
if (surfaceRect == null) {
|
||||||
|
surfaceRect = computeSurfaceLayoutArea(false);
|
||||||
|
}
|
||||||
if (surfaceView != null) {
|
if (surfaceView != null) {
|
||||||
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
|
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
|
||||||
bringChildToFront(surfaceView);
|
bringChildToFront(surfaceView);
|
||||||
}
|
}
|
||||||
View currentBottomView = getCurrentBottomView();
|
View currentBottomView = getCurrentBottomView();
|
||||||
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
|
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
|
||||||
if (bottomViewRect == null)
|
if (bottomViewRect == null) {
|
||||||
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, surfaceRect);
|
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, surfaceRect);
|
||||||
|
}
|
||||||
if (currentBottomView != null) {
|
if (currentBottomView != null) {
|
||||||
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
|
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
|
||||||
}
|
}
|
||||||
|
|
@ -810,15 +878,18 @@ public class SwipeLayout extends FrameLayout {
|
||||||
void layoutLayDown() {
|
void layoutLayDown() {
|
||||||
View surfaceView = getSurfaceView();
|
View surfaceView = getSurfaceView();
|
||||||
Rect surfaceRect = mViewBoundCache.get(surfaceView);
|
Rect surfaceRect = mViewBoundCache.get(surfaceView);
|
||||||
if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
|
if (surfaceRect == null) {
|
||||||
|
surfaceRect = computeSurfaceLayoutArea(false);
|
||||||
|
}
|
||||||
if (surfaceView != null) {
|
if (surfaceView != null) {
|
||||||
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
|
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
|
||||||
bringChildToFront(surfaceView);
|
bringChildToFront(surfaceView);
|
||||||
}
|
}
|
||||||
View currentBottomView = getCurrentBottomView();
|
View currentBottomView = getCurrentBottomView();
|
||||||
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
|
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
|
||||||
if (bottomViewRect == null)
|
if (bottomViewRect == null) {
|
||||||
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
|
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
|
||||||
|
}
|
||||||
if (currentBottomView != null) {
|
if (currentBottomView != null) {
|
||||||
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
|
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
|
||||||
}
|
}
|
||||||
|
|
@ -827,7 +898,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
private boolean mIsBeingDragged;
|
private boolean mIsBeingDragged;
|
||||||
|
|
||||||
private void checkCanDrag(MotionEvent ev) {
|
private void checkCanDrag(MotionEvent ev) {
|
||||||
if (mIsBeingDragged) return;
|
if (mIsBeingDragged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (getOpenStatus() == Status.Middle) {
|
if (getOpenStatus() == Status.Middle) {
|
||||||
mIsBeingDragged = true;
|
mIsBeingDragged = true;
|
||||||
return;
|
return;
|
||||||
|
|
@ -844,14 +917,18 @@ public class SwipeLayout extends FrameLayout {
|
||||||
dragEdge = DragEdge.Left;
|
dragEdge = DragEdge.Left;
|
||||||
} else if (distanceX < 0 && isRightSwipeEnabled()) {
|
} else if (distanceX < 0 && isRightSwipeEnabled()) {
|
||||||
dragEdge = DragEdge.Right;
|
dragEdge = DragEdge.Right;
|
||||||
} else return;
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (distanceY > 0 && isTopSwipeEnabled()) {
|
if (distanceY > 0 && isTopSwipeEnabled()) {
|
||||||
dragEdge = DragEdge.Top;
|
dragEdge = DragEdge.Top;
|
||||||
} else if (distanceY < 0 && isBottomSwipeEnabled()) {
|
} else if (distanceY < 0 && isBottomSwipeEnabled()) {
|
||||||
dragEdge = DragEdge.Bottom;
|
dragEdge = DragEdge.Bottom;
|
||||||
} else return;
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setCurrentDragEdge(dragEdge);
|
setCurrentDragEdge(dragEdge);
|
||||||
}
|
}
|
||||||
|
|
@ -955,7 +1032,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (!isSwipeEnabled()) return super.onTouchEvent(event);
|
if (!isSwipeEnabled()) {
|
||||||
|
return super.onTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
gestureDetector.onTouchEvent(event);
|
gestureDetector.onTouchEvent(event);
|
||||||
|
|
@ -1098,7 +1177,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performAdapterViewItemClick() {
|
private void performAdapterViewItemClick() {
|
||||||
if (getOpenStatus() != Status.Close) return;
|
if (getOpenStatus() != Status.Close) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ViewParent t = getParent();
|
ViewParent t = getParent();
|
||||||
if (t instanceof AdapterView) {
|
if (t instanceof AdapterView) {
|
||||||
AdapterView view = (AdapterView) t;
|
AdapterView view = (AdapterView) t;
|
||||||
|
|
@ -1111,12 +1192,16 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean performAdapterViewItemLongClick() {
|
private boolean performAdapterViewItemLongClick() {
|
||||||
if (getOpenStatus() != Status.Close) return false;
|
if (getOpenStatus() != Status.Close) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ViewParent t = getParent();
|
ViewParent t = getParent();
|
||||||
if (t instanceof AdapterView) {
|
if (t instanceof AdapterView) {
|
||||||
AdapterView view = (AdapterView) t;
|
AdapterView view = (AdapterView) t;
|
||||||
int p = view.getPositionForView(SwipeLayout.this);
|
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);
|
long vId = view.getItemIdAtPosition(p);
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
try {
|
try {
|
||||||
|
|
@ -1229,7 +1314,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
* @param max max distance in dp unit
|
* @param max max distance in dp unit
|
||||||
*/
|
*/
|
||||||
public void setDragDistance(int max) {
|
public void setDragDistance(int max) {
|
||||||
if (max < 0) max = 0;
|
if (max < 0) {
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
mDragDistance = dp2px(max);
|
mDragDistance = dp2px(max);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
@ -1262,7 +1349,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
* return null if there is no surface view(no children)
|
* return null if there is no surface view(no children)
|
||||||
*/
|
*/
|
||||||
public View getSurfaceView() {
|
public View getSurfaceView() {
|
||||||
if (getChildCount() == 0) return null;
|
if (getChildCount() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return getChildAt(getChildCount() - 1);
|
return getChildAt(getChildCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1307,11 +1396,14 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
int surfaceLeft = surfaceView.getLeft();
|
int surfaceLeft = surfaceView.getLeft();
|
||||||
int surfaceTop = surfaceView.getTop();
|
int surfaceTop = surfaceView.getTop();
|
||||||
if (surfaceLeft == getPaddingLeft() && surfaceTop == getPaddingTop()) return Status.Close;
|
if (surfaceLeft == getPaddingLeft() && surfaceTop == getPaddingTop() && !mIsBeingDragged) {
|
||||||
|
return Status.Close;
|
||||||
|
}
|
||||||
|
|
||||||
if (surfaceLeft == (getPaddingLeft() - mDragDistance) || surfaceLeft == (getPaddingLeft() + mDragDistance)
|
if (surfaceLeft == (getPaddingLeft() - mDragDistance) || surfaceLeft == (getPaddingLeft() + mDragDistance)
|
||||||
|| surfaceTop == (getPaddingTop() - mDragDistance) || surfaceTop == (getPaddingTop() + mDragDistance))
|
|| surfaceTop == (getPaddingTop() - mDragDistance) || surfaceTop == (getPaddingTop() + mDragDistance)) {
|
||||||
return Status.Open;
|
return Status.Open;
|
||||||
|
}
|
||||||
|
|
||||||
return Status.Middle;
|
return Status.Middle;
|
||||||
}
|
}
|
||||||
|
|
@ -1333,36 +1425,56 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
float willOpenPercent = (isCloseBeforeDragged ? mWillOpenPercentAfterClose : mWillOpenPercentAfterOpen);
|
float willOpenPercent = (isCloseBeforeDragged ? mWillOpenPercentAfterClose : mWillOpenPercentAfterOpen);
|
||||||
if (currentDragEdge == DragEdge.Left) {
|
if (currentDragEdge == DragEdge.Left) {
|
||||||
if (xvel > minVelocity) open();
|
if (xvel > minVelocity) {
|
||||||
else if (xvel < -minVelocity) close();
|
open();
|
||||||
else {
|
} else if (xvel < -minVelocity) {
|
||||||
|
close();
|
||||||
|
} else {
|
||||||
float openPercent = 1f * getSurfaceView().getLeft() / mDragDistance;
|
float openPercent = 1f * getSurfaceView().getLeft() / mDragDistance;
|
||||||
if (openPercent > willOpenPercent) open();
|
if (openPercent > willOpenPercent) {
|
||||||
else close();
|
open();
|
||||||
|
} else {
|
||||||
|
close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (currentDragEdge == DragEdge.Right) {
|
} else if (currentDragEdge == DragEdge.Right) {
|
||||||
if (xvel > minVelocity) close();
|
if (xvel > minVelocity) {
|
||||||
else if (xvel < -minVelocity) open();
|
close();
|
||||||
else {
|
} else if (xvel < -minVelocity) {
|
||||||
|
open();
|
||||||
|
} else {
|
||||||
float openPercent = 1f * (-getSurfaceView().getLeft()) / mDragDistance;
|
float openPercent = 1f * (-getSurfaceView().getLeft()) / mDragDistance;
|
||||||
if (openPercent > willOpenPercent) open();
|
if (openPercent > willOpenPercent) {
|
||||||
else close();
|
open();
|
||||||
|
} else {
|
||||||
|
close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (currentDragEdge == DragEdge.Top) {
|
} else if (currentDragEdge == DragEdge.Top) {
|
||||||
if (yvel > minVelocity) open();
|
if (yvel > minVelocity) {
|
||||||
else if (yvel < -minVelocity) close();
|
open();
|
||||||
else {
|
} else if (yvel < -minVelocity) {
|
||||||
|
close();
|
||||||
|
} else {
|
||||||
float openPercent = 1f * getSurfaceView().getTop() / mDragDistance;
|
float openPercent = 1f * getSurfaceView().getTop() / mDragDistance;
|
||||||
if (openPercent > willOpenPercent) open();
|
if (openPercent > willOpenPercent) {
|
||||||
else close();
|
open();
|
||||||
|
} else {
|
||||||
|
close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (currentDragEdge == DragEdge.Bottom) {
|
} else if (currentDragEdge == DragEdge.Bottom) {
|
||||||
if (yvel > minVelocity) close();
|
if (yvel > minVelocity) {
|
||||||
else if (yvel < -minVelocity) open();
|
close();
|
||||||
else {
|
} else if (yvel < -minVelocity) {
|
||||||
|
open();
|
||||||
|
} else {
|
||||||
float openPercent = 1f * (-getSurfaceView().getTop()) / mDragDistance;
|
float openPercent = 1f * (-getSurfaceView().getTop()) / mDragDistance;
|
||||||
if (openPercent > willOpenPercent) open();
|
if (openPercent > willOpenPercent) {
|
||||||
else close();
|
open();
|
||||||
|
} else {
|
||||||
|
close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1445,9 +1557,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
if (smooth)
|
if (smooth) {
|
||||||
mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(), getPaddingTop());
|
mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(), getPaddingTop());
|
||||||
else {
|
} else {
|
||||||
Rect rect = computeSurfaceLayoutArea(false);
|
Rect rect = computeSurfaceLayoutArea(false);
|
||||||
dx = rect.left - surface.getLeft();
|
dx = rect.left - surface.getLeft();
|
||||||
dy = rect.top - surface.getTop();
|
dy = rect.top - surface.getTop();
|
||||||
|
|
@ -1467,9 +1579,11 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggle(boolean smooth) {
|
public void toggle(boolean smooth) {
|
||||||
if (getOpenStatus() == Status.Open)
|
if (getOpenStatus() == Status.Open) {
|
||||||
close(smooth);
|
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) {
|
private Rect computeSurfaceLayoutArea(boolean open) {
|
||||||
int l = getPaddingLeft(), t = getPaddingTop();
|
int l = getPaddingLeft(), t = getPaddingTop();
|
||||||
if (open) {
|
if (open) {
|
||||||
if (mCurrentDragEdge == DragEdge.Left)
|
if (mCurrentDragEdge == DragEdge.Left) {
|
||||||
l = getPaddingLeft() + mDragDistance;
|
l = getPaddingLeft() + mDragDistance;
|
||||||
else if (mCurrentDragEdge == DragEdge.Right)
|
} else if (mCurrentDragEdge == DragEdge.Right) {
|
||||||
l = getPaddingLeft() - mDragDistance;
|
l = getPaddingLeft() - mDragDistance;
|
||||||
else if (mCurrentDragEdge == DragEdge.Top)
|
} else if (mCurrentDragEdge == DragEdge.Top) {
|
||||||
t = getPaddingTop() + mDragDistance;
|
t = getPaddingTop() + mDragDistance;
|
||||||
else t = getPaddingTop() - mDragDistance;
|
} else {
|
||||||
|
t = getPaddingTop() - mDragDistance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Rect(l, t, l + getMeasuredWidth(), t + getMeasuredHeight());
|
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;
|
int bl = rect.left, bt = rect.top, br = rect.right, bb = rect.bottom;
|
||||||
if (mode == ShowMode.PullOut) {
|
if (mode == ShowMode.PullOut) {
|
||||||
if (mCurrentDragEdge == DragEdge.Left)
|
if (mCurrentDragEdge == DragEdge.Left) {
|
||||||
bl = rect.left - mDragDistance;
|
bl = rect.left - mDragDistance;
|
||||||
else if (mCurrentDragEdge == DragEdge.Right)
|
} else if (mCurrentDragEdge == DragEdge.Right) {
|
||||||
bl = rect.right;
|
bl = rect.right;
|
||||||
else if (mCurrentDragEdge == DragEdge.Top)
|
} else if (mCurrentDragEdge == DragEdge.Top) {
|
||||||
bt = rect.top - mDragDistance;
|
bt = rect.top - mDragDistance;
|
||||||
else bt = rect.bottom;
|
} else {
|
||||||
|
bt = rect.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
|
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
|
||||||
bb = rect.bottom;
|
bb = rect.bottom;
|
||||||
|
|
@ -1514,13 +1632,15 @@ public class SwipeLayout extends FrameLayout {
|
||||||
br = rect.right;
|
br = rect.right;
|
||||||
}
|
}
|
||||||
} else if (mode == ShowMode.LayDown) {
|
} else if (mode == ShowMode.LayDown) {
|
||||||
if (mCurrentDragEdge == DragEdge.Left)
|
if (mCurrentDragEdge == DragEdge.Left) {
|
||||||
br = bl + mDragDistance;
|
br = bl + mDragDistance;
|
||||||
else if (mCurrentDragEdge == DragEdge.Right)
|
} else if (mCurrentDragEdge == DragEdge.Right) {
|
||||||
bl = br - mDragDistance;
|
bl = br - mDragDistance;
|
||||||
else if (mCurrentDragEdge == DragEdge.Top)
|
} else if (mCurrentDragEdge == DragEdge.Top) {
|
||||||
bb = bt + mDragDistance;
|
bb = bt + mDragDistance;
|
||||||
else bt = bb - mDragDistance;
|
} else {
|
||||||
|
bt = bb - mDragDistance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return new Rect(bl, bt, br, bb);
|
return new Rect(bl, bt, br, bb);
|
||||||
|
|
@ -1630,7 +1750,9 @@ public class SwipeLayout extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getCurrentOffset() {
|
private float getCurrentOffset() {
|
||||||
if (mCurrentDragEdge == null) return 0;
|
if (mCurrentDragEdge == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return mEdgeSwipesOffset[mCurrentDragEdge.ordinal()];
|
return mEdgeSwipesOffset[mCurrentDragEdge.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.daimajia.swipe.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.support.v4.widget.CursorAdapter;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
|
@ -14,6 +13,8 @@ import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.cursoradapter.widget.CursorAdapter;
|
||||||
|
|
||||||
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.daimajia.swipe.adapters;
|
package com.daimajia.swipe.adapters;
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.daimajia.swipe.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
|
@ -14,6 +13,8 @@ import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.cursoradapter.widget.SimpleCursorAdapter;
|
||||||
|
|
||||||
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue