Skip to content

Commit

Permalink
fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaosong520 committed Apr 2, 2018
1 parent ddfba54 commit cb7a68d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and support for the linkage, dialog . It's very easy to use , you also can cust
### Gradle

```java
compile 'com.contrarywind:Android-PickerView:4.1.1'
compile 'com.contrarywind:Android-PickerView:4.1.2'
```

### Maven
Expand All @@ -48,7 +48,7 @@ compile 'com.contrarywind:Android-PickerView:4.1.1'
<dependency>
<groupId>com.contrarywind</groupId>
<artifactId>Android-PickerView</artifactId>
<version>4.1.1</version>
<version>4.1.2</version>
<type>pom</type>
</dependency>
```
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ Wiki文档,Wiki文档,Wiki文档 ~ 重要的事情说三遍 ~
startDate.set(2013,0,1);
 endDate.set(2020,11,1);

#### V4.1.2 版本更新说明(2018-4-02)
- 修复WheelView 偶现滑动item越界问题。

#### V4.1.1 版本更新说明(2018-4-02)
- 修复不联动选项,初始默认选中项设置无效的问题。

- 修复Item 的值重名时,回调的position始终为第一个item的问题。

- 修复WheelView 偶现滑动越界逻辑问题。


#### 更多历史版本详情,请查阅:[更新说明(3.x版本)](https://github.com/Bigkoo/Android-PickerView/wiki/%E6%9B%B4%E6%96%B0%E8%AF%B4%E6%98%8E%EF%BC%883.x%E7%89%88%E6%9C%AC%EF%BC%89)

Expand All @@ -81,7 +83,7 @@ Wiki文档,Wiki文档,Wiki文档 ~ 重要的事情说三遍 ~

#### 1.添加Jcenter仓库 Gradle依赖:
```java
compile 'com.contrarywind:Android-PickerView:4.1.1'
compile 'com.contrarywind:Android-PickerView:4.1.2'
```
或者

Expand All @@ -90,7 +92,7 @@ compile 'com.contrarywind:Android-PickerView:4.1.1'
<dependency>
<groupId>com.contrarywind</groupId>
<artifactId>Android-PickerView</artifactId>
<version>4.1.1</version>
<version>4.1.2</version>
<type>pom</type>
</dependency>
```
Expand Down
6 changes: 3 additions & 3 deletions pickerview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 25
versionName "4.1.0"
versionCode 27
versionName "4.1.2"
}
buildTypes {
release {
Expand All @@ -38,7 +38,7 @@ publish {
userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name
groupId = 'com.contrarywind'//JCenter上显示的路径 path
artifactId = 'Android-PickerView'//项目名称 project name
publishVersion = '4.1.0'//版本号 version code
publishVersion = '4.1.2'//版本号 version code
desc = 'this is a pickerview for android'//项目描述 description
website = 'https://github.com/Bigkoo/Android-PickerView' //项目网址链接 link
}
Expand Down
6 changes: 3 additions & 3 deletions wheelview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 25
versionName "4.0.2"
versionCode 27
versionName "4.0.4"
}
buildTypes {
release {
Expand All @@ -38,7 +38,7 @@ publish {
userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name
groupId = 'com.contrarywind'//JCenter上显示的路径 path
artifactId = 'wheelview'//项目名称 project name
publishVersion = '4.0.2'//版本号 version code
publishVersion = '4.0.4'//版本号 version code
desc = 'this is a wheelview for android'//项目描述 description
website = 'https://github.com/Bigkoo/Android-PickerView' //项目网址链接 link
}
Expand Down
37 changes: 19 additions & 18 deletions wheelview/src/main/java/com/contrarywind/view/WheelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ protected void onDraw(Canvas canvas) {
Object visibles[] = new Object[itemsVisible];
//滚动的Y值高度除去每行Item的高度,得到滚动了多少个item,即change数
change = (int) (totalScrollY / itemHeight);
// Log.d("change", "" + change);

try {
//滚动中实际的预选中的item(即经过了中间位置的item) = 滑动前的位置 + 滑动相对位置
Expand Down Expand Up @@ -627,6 +628,10 @@ public boolean onTouchEvent(MotionEvent event) {
boolean eventConsumed = gestureDetector.onTouchEvent(event);
boolean isIgnore = false;//超过边界滑动时,不再绘制UI。

float top = -initPosition * itemHeight;
float bottom = (adapter.getItemsCount() - 1 - initPosition) * itemHeight;
float ratio = 0.25f;

switch (event.getAction()) {
//按下
case MotionEvent.ACTION_DOWN:
Expand All @@ -641,32 +646,28 @@ public boolean onTouchEvent(MotionEvent event) {
previousY = event.getRawY();
totalScrollY = totalScrollY + dy;

float ratio = 0.5f;
// 边界处理。
// 非循环模式下,边界处理。
if (!isLoop) {
float top = -initPosition * itemHeight;
float bottom = (adapter.getItemsCount() - 1 - initPosition) * itemHeight;

if (totalScrollY + itemHeight * ratio < top) {
top = totalScrollY - dy;

} else if (totalScrollY - itemHeight * ratio > bottom) {
bottom = totalScrollY - dy;
}

if (totalScrollY < top) {
totalScrollY = (int) top;
isIgnore = true;
} else if (totalScrollY > bottom) {
totalScrollY = (int) bottom;
if (totalScrollY - itemHeight * ratio < top
|| totalScrollY + itemHeight * ratio > bottom) {
//快滑动到边界了,设置已滑动到边界的标志
totalScrollY -= dy;
isIgnore = true;
}
}
break;

case MotionEvent.ACTION_UP:
default:

if (totalScrollY - itemHeight * ratio < top
|| totalScrollY + itemHeight * ratio > bottom) {//设置已滑动到边界的标志
isIgnore = true;
break;
}

if (!eventConsumed) {//未消费掉事件
// Log.e("eventConsumed", "eventConsumed...");

/**
*@describe <关于弧长的计算>
Expand Down Expand Up @@ -698,7 +699,7 @@ public boolean onTouchEvent(MotionEvent event) {
}
break;
}
if (!isIgnore) {
if (!isIgnore && event.getAction() != MotionEvent.ACTION_DOWN) {
invalidate();
}
return true;
Expand Down

0 comments on commit cb7a68d

Please sign in to comment.