Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Leaqi committed Jun 16, 2023
1 parent 6f1270b commit 1feba6b
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SwipeDrawer · [![Star](https://img.shields.io/github/stars/Leaqi/SwipeDrawer?color=fb6698&label=Star "Star")](https://github.com/Leaqi/SwipeDrawer/stargazers "Star") [![Fork](https://img.shields.io/github/forks/Leaqi/SwipeDrawer?color=2196f3&label=Fork "Fork")](https://github.com/Leaqi/SwipeDrawer/network/members "Fork") [![API](https://img.shields.io/badge/API-14%2B-04d8bb "API")](https://github.com/Leaqi/SwipeDrawer/ "API") [![JitPack](https://jitpack.io/v/Leaqi/SwipeDrawer.svg "JitPack")](https://jitpack.io/#cn.Leaqi/SwipeDrawer "JitPack") [![Release](https://img.shields.io/github/v/release/Leaqi/SwipeDrawer?label=Release&color=06da47 "Release")](https://github.com/Leaqi/SwipeDrawer/releases "Release") [![License](https://img.shields.io/badge/License-Apache--2.0-e0b003 "License")](https://github.com/Leaqi/SwipeDrawer/blob/main/LICENSE "License") [![Download Demo Apk](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "Download Demo Apk")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.5/demo.apk "Download Demo Apk")
# SwipeDrawer · [![Star](https://img.shields.io/github/stars/Leaqi/SwipeDrawer?color=fb6698&label=Star "Star")](https://github.com/Leaqi/SwipeDrawer/stargazers "Star") [![Fork](https://img.shields.io/github/forks/Leaqi/SwipeDrawer?color=2196f3&label=Fork "Fork")](https://github.com/Leaqi/SwipeDrawer/network/members "Fork") [![API](https://img.shields.io/badge/API-14%2B-04d8bb "API")](https://github.com/Leaqi/SwipeDrawer/ "API") [![JitPack](https://jitpack.io/v/Leaqi/SwipeDrawer.svg "JitPack")](https://jitpack.io/#cn.Leaqi/SwipeDrawer "JitPack") [![Release](https://img.shields.io/github/v/release/Leaqi/SwipeDrawer?label=Release&color=06da47 "Release")](https://github.com/Leaqi/SwipeDrawer/releases "Release") [![License](https://img.shields.io/badge/License-Apache--2.0-e0b003 "License")](https://github.com/Leaqi/SwipeDrawer/blob/main/LICENSE "License") [![Download Demo Apk](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "Download Demo Apk")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.6/demo.apk "Download Demo Apk")
#### 中文 README | [English README](https://github.com/Leaqi/SwipeDrawer/blob/main/README_en.md "English README")
Android SwipeDrawer滑动抽屉库,可同时添加上下左右四个方向抽屉布局,抽屉打开模式有抽屉模式、覆盖模式、固定模式三种,支持无限嵌套,支持边缘滑动打开等,SwipeDrawer还可以当做下拉刷新布局使用,支持ListView、RecyclerView、GridView、ScrollView等。
#### 中文:
Expand All @@ -21,7 +21,7 @@ Android SwipeDrawer滑动抽屉库,可同时添加上下左右四个方向抽

dependencies {
...
implementation 'cn.Leaqi:SwipeDrawer:1.5'
implementation 'cn.Leaqi:SwipeDrawer:1.6'
}

在布局文件中加入 `SwipeDrawer`
Expand Down
4 changes: 2 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SwipeDrawer · [![Star](https://img.shields.io/github/stars/Leaqi/SwipeDrawer?color=fb6698&label=Star "Star")](https://github.com/Leaqi/SwipeDrawer/stargazers "Star") [![Fork](https://img.shields.io/github/forks/Leaqi/SwipeDrawer?color=2196f3&label=Fork "Fork")](https://github.com/Leaqi/SwipeDrawer/network/members "Fork") [![API](https://img.shields.io/badge/API-14%2B-04d8bb "API")](https://github.com/Leaqi/SwipeDrawer/ "API") [![JitPack](https://jitpack.io/v/Leaqi/SwipeDrawer.svg "JitPack")](https://jitpack.io/#cn.Leaqi/SwipeDrawer "JitPack") [![Release](https://img.shields.io/github/v/release/Leaqi/SwipeDrawer?label=Release&color=06da47 "Release")](https://github.com/Leaqi/SwipeDrawer/releases "Release") [![License](https://img.shields.io/badge/License-Apache--2.0-e0b003 "License")](https://github.com/Leaqi/SwipeDrawer/blob/main/LICENSE "License") [![Download Demo Apk](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "Download Demo Apk")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.5/demo.apk "Download Demo Apk")
# SwipeDrawer · [![Star](https://img.shields.io/github/stars/Leaqi/SwipeDrawer?color=fb6698&label=Star "Star")](https://github.com/Leaqi/SwipeDrawer/stargazers "Star") [![Fork](https://img.shields.io/github/forks/Leaqi/SwipeDrawer?color=2196f3&label=Fork "Fork")](https://github.com/Leaqi/SwipeDrawer/network/members "Fork") [![API](https://img.shields.io/badge/API-14%2B-04d8bb "API")](https://github.com/Leaqi/SwipeDrawer/ "API") [![JitPack](https://jitpack.io/v/Leaqi/SwipeDrawer.svg "JitPack")](https://jitpack.io/#cn.Leaqi/SwipeDrawer "JitPack") [![Release](https://img.shields.io/github/v/release/Leaqi/SwipeDrawer?label=Release&color=06da47 "Release")](https://github.com/Leaqi/SwipeDrawer/releases "Release") [![License](https://img.shields.io/badge/License-Apache--2.0-e0b003 "License")](https://github.com/Leaqi/SwipeDrawer/blob/main/LICENSE "License") [![Download Demo Apk](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "Download Demo Apk")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.6/demo.apk "Download Demo Apk")
#### English README | [中文 README](https://github.com/Leaqi/SwipeDrawer/ "中文 README")
Android SwipeDrawer sliding drawer library can add up, down, left and right drawer layouts at the same time. There are three drawer opening modes: drawer mode, overlay mode and fixed mode. It supports unlimited nesting and edge sliding opening. Swipedrawer can also be used as a drop-down refresh layout, and supports listview, recyclerview, GridView, Scrollview, etc.

Expand All @@ -22,7 +22,7 @@ Add `SwipeDrawer` dependencies:

dependencies {
...
implementation 'cn.Leaqi:SwipeDrawer:1.5'
implementation 'cn.Leaqi:SwipeDrawer:1.6'
}

Add `SwipeDrawer` to the layout file :
Expand Down
2 changes: 1 addition & 1 deletion apk/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Demo-App · [![下载APK](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "下载APK")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.5/demo.apk "下载APK")
# Demo-App · [![下载APK](https://img.shields.io/badge/Download-Demo%20Apk-45c703 "下载APK")](https://github.com/Leaqi/SwipeDrawer/releases/download/1.6/demo.apk "下载APK")
## 图片预览 · [![查看更多](https://img.shields.io/badge/More-%E6%9F%A5%E7%9C%8B%E6%9B%B4%E5%A4%9A-blue "查看更多")](https://Leaqi.github.io/SwipeDrawer/pics.html "查看更多")
### Demo Home:
[![Demo Home](https://p.ssl.qhimg.com/t01b36f1353d11068a0.jpg "Demo Home")](https://Leaqi.github.io/SwipeDrawer/pics.html "Demo Home")
Expand Down
Binary file modified apk/demo-app.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "cn.leaqi.drawerapp"
minSdkVersion 16
targetSdkVersion 29
versionCode 5
versionName "1.5"
versionCode 6
versionName "1.6"
}
buildTypes {
release {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_demo11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
app:duration="500"
app:shrinkRange="1"
app:dragDamping="5"
app:turnCancel="0dp"
app:maxDragSize="200dp"
app:mainScroll="@+id/mainList"
app:topLayout="@+id/topLayout"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_demo12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:background="#f9f9f9"
app:shrinkRange="1.2"
app:dragDamping="4"
app:turnCancel="0dp"
app:maxDragSize="200dp"
app:mainScroll="@+id/mainList"
app:topLayout="@+id/topLayout"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_demo13.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
app:duration="360"
app:shrinkRange="1"
app:dragDamping="4"
app:turnCancel="0dp"
app:maxDragSize="120dp"
app:dragClose="false"
app:interpolator="@android:anim/anticipate_overshoot_interpolator"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_demo14.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
app:dragClose="false"
app:shrinkRange="1"
app:dragDamping="5"
app:turnCancel="0dp"
app:maxDragSize="200dp"
app:mainScroll="@+id/mainList"
app:topLayout="@+id/topLayout">
Expand Down
4 changes: 2 additions & 2 deletions drawer/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.Leaqi'
version='1.5'
version='1.6'

android {
compileSdkVersion 29
Expand All @@ -10,7 +10,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 5
versionCode 6
versionName version
consumerProguardFiles 'consumer-rules.pro'
}
Expand Down
35 changes: 29 additions & 6 deletions drawer/src/main/java/cn/leaqi/drawer/SwipeDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public class SwipeDrawer extends ViewGroup {
private int rightDragRange = 0;
private int bottomDragRange = 0;
private int dragSlop = 5;
private int turnCancel = 10;
private int maxDragSize = 0;
private int dragCloseType = 0;
private int duration = 200;
Expand All @@ -141,6 +142,9 @@ public class SwipeDrawer extends ViewGroup {
private int downX = 0;
private int downY = 0;
private int downMs = 0;
private int moveSize = 0;
private int lastSize = 0;
private int turnSize = 0;
private int getPointerId = INVALID_POINTER;
private int getLastMoveX = 0;
private int getLastMoveY = 0;
Expand Down Expand Up @@ -207,6 +211,7 @@ private void attrInit(Context context, AttributeSet attr) {
final int getRightDragRange = attrArr.getDimensionPixelSize(R.styleable.SwipeDrawer_rightDragRange, rightDragRange);
final int getBottomDragRange = attrArr.getDimensionPixelSize(R.styleable.SwipeDrawer_bottomDragRange, bottomDragRange);
final int getDragSlop = attrArr.getDimensionPixelSize(R.styleable.SwipeDrawer_dragSlop, dragSlop);
final int getTurnCancel = attrArr.getDimensionPixelSize(R.styleable.SwipeDrawer_turnCancel, turnCancel);
final int getDragCloseType = attrArr.getInteger(R.styleable.SwipeDrawer_dragCloseType, dragCloseType);
final int getMaxDragSize = attrArr.getDimensionPixelSize(R.styleable.SwipeDrawer_maxDragSize, maxDragSize);
final int getDuration = attrArr.getInteger(R.styleable.SwipeDrawer_duration, duration);
Expand Down Expand Up @@ -258,6 +263,7 @@ private void attrInit(Context context, AttributeSet attr) {
setRightDragRange(getRightDragRange);
setBottomDragRange(getBottomDragRange);
setDragSlop(getDragSlop);
setTurnCancel(getTurnCancel);
setMaxDragSize(getMaxDragSize);
setMaskColor(getMaskColor);
setDuration(getDuration);
Expand Down Expand Up @@ -401,6 +407,11 @@ public void setDragSlop(int num) {
dragSlop = num;
}

public void setTurnCancel(int num) {
if (num < 0) num = 0;
turnCancel = num;
}

public void setMaxDragSize(int num) {
if (num < 0) num = 0;
maxDragSize = num;
Expand Down Expand Up @@ -803,6 +814,10 @@ public int getDragSlop() {
return dragSlop;
}

public int getTurnCancel() {
return turnCancel;
}

public int getMaxDragSize() {
return maxDragSize;
}
Expand Down Expand Up @@ -1579,6 +1594,18 @@ private void checkRange(ViewUtils viewUtils, boolean isCover) {
}
if (isShow) mainSize = viewSize - mainSize;
arriveRange = mainSize >= Math.round(viewSize / shrinkRange);
if (turnCancel > 0) {
final boolean isReverse = isShow ? (isRight || isBottom) : (isLeft || isTop);
if ((isReverse && moveSize <= lastSize) || (!isReverse && moveSize >= lastSize)) {
turnSize += isReverse ? lastSize - moveSize : moveSize - lastSize;
if (turnSize > turnCancel) {
arriveRange = false;
}
} else {
turnSize = 0;
}
lastSize = moveSize;
}
}
}

Expand Down Expand Up @@ -1762,7 +1789,7 @@ public boolean onTouchEvent(MotionEvent ev) {
final float getDamping = dragDamping > 0 && dragDamping < 100 ? (float)dragDamping / 10 : 1;
getLastShiftX = moveX - downX + getLastMoveX;
getLastShiftY = moveY - downY + getLastMoveY;
int moveSize = isLeft || isRight ? getLastShiftX : getLastShiftY;
moveSize = isLeft || isRight ? getLastShiftX : getLastShiftY;
moveSize *= getDamping;
if ((((isLeft || isTop) && ((isShow && moveSize > 0) || (!isShow && moveSize < 0)))) || (((isRight || isBottom) && ((isShow && moveSize < 0) || (!isShow && moveSize > 0))))) moveSize = 0;
if (Math.abs(moveSize) >= newSize) {
Expand Down Expand Up @@ -1820,11 +1847,7 @@ public boolean onTouchEvent(MotionEvent ev) {
final ViewUtils viewUtils = getViewUtils(inDirection);
if (viewUtils != null) {
checkRange(viewUtils, isCover);
if (shrinkRange == 0) {
animRecovery(isShow, true, true);
if (onDrawerState != null) onDrawerState.onCancel(inDirection);
if (onDrawerChange != null) onDrawerChange.onChange(this, STATE_CANCEL, 0);
} else if (arriveRange) {
if (arriveRange && shrinkRange > 0) {
isShow = !isShow;
animRecovery(isShow, true, true);
if (isShow) {
Expand Down
1 change: 1 addition & 0 deletions drawer/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<attr name="rightDragRange" format="dimension" />
<attr name="bottomDragRange" format="dimension" />
<attr name="dragSlop" format="dimension" />
<attr name="turnCancel" format="dimension" />
<attr name="maxDragSize" format="dimension" />
<attr name="duration" format="integer" />
<attr name="interpolator" format="reference" />
Expand Down

0 comments on commit 1feba6b

Please sign in to comment.