Skip to content

Commit

Permalink
2.6.5 (#79)
Browse files Browse the repository at this point in the history
* Fix a bug.

* Optimize code

* Update Readme.
  • Loading branch information
zhpanvip authored Jan 4, 2020
1 parent aeba256 commit e2de297
Show file tree
Hide file tree
Showing 32 changed files with 190 additions and 17 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,33 @@

### 2.setIndicatorStyle

BannerViewPager supports three Indicator Styles now. It's also support to custom indicator style,just need extends BaseIndicatorView or implement the IIndicator and override methods, then you can draw Indicators for whatever you want.
BannerViewPager supports three Indicator Styles now.

[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java)

| CIRCLE | DASH | ROUND_RECT |
|--|--|--|
| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_circle.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_dash.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_round_rect.gif) |

### 3.setIndicatorSlideMode
### 3.Custom Indicator

It's also support to custom indicator style,just need extends BaseIndicatorView or implement the IIndicator and override methods, then you can draw Indicators for whatever you want.

[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java)

| Figure Indicator | Drawable Indicator | Indicator below of Banner |
|--|--|--|
| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom1.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom2.gif) |


### 4.setIndicatorSlideMode

| NORMAL | SMOOTH |
|--|--|
| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_normal.gif) | ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_smooth.gif) |


### 4.setPageTransformerStyle
### 5.setPageTransformerStyle

[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.java)

Expand Down Expand Up @@ -384,6 +395,14 @@ public class FigureIndicatorView extends BaseIndicatorView {
- [x] Fix issue #34 which Indicator smooth slide problem(2.6.1).
- [ ] Migrate to ViewPager2 (3.0.0)

## Sponsor

**开源不易 随心赞赏**

| Alipay | WeChat Pay |
|--|--|
| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_alipay.jpb) | ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_wechat.png) |


## If you have any question you can scan the QR code to join the QQ group to communicate.

Expand Down
27 changes: 23 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,34 @@
| ![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi.gif) |![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi_scale.gif) |![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi_overlay.gif) |

### 2.setIndicatorStyle
BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义IndicatorView的功能。只要继承BaseIndicatorView或者实现IIndicator接口,并重写相应方法,就可以为所欲为的打造任意的Indicator了。
BannerViewPager目前已支持三种IndicatorViewStyle,分别如下:

[IndicatorViewStyle Demo](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java)

| CIRCLE | DASH | ROUND_RECT |
|--|--|--|
| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_circle.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_dash.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_round_rect.gif) |

### 3.setIndicatorSlideMode
### 3.Custom Indicator

同时BannerViewPager还提供了自定义IndicatorView的功能。只要继承BaseIndicatorView或者实现IIndicator接口,并重写相应方法,就可以为所欲为的打造任意的Indicator了。

[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java)

| Figure Indicator | Drawable Indicator | Indicator below of Banner |
|--|--|--|
| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom1.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom2.gif) |



### 4.setIndicatorSlideMode

| NORMAL | SMOOTH |
|--|--|
| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_normal.gif) | ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_smooth.gif) |


### 4.setPageTransformerStyle
### 5.setPageTransformerStyle

[TransformStyle Demo](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.java)

Expand All @@ -52,7 +64,6 @@ BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义I
| 预览 | ![STACK](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_stack.gif) | ![ROTATE_DOWN](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_rotate.gif) | ![DEPTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_depth.gif) |![ACCORDION](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_accordion.gif) |



## 开放API

| 方法名 | 方法描述 | 说明 |
Expand Down Expand Up @@ -385,6 +396,14 @@ public class FigureIndicatorView extends BaseIndicatorView {
- [x] 修复 issue #34 Indicator 在Smooth模式下存在的问题 (2.6.1).
- [ ] ViewPager更换为ViewPager2 (3.0.0)

## Sponsor

**开源不易 随心赞赏**

| 支付宝 | 微信支付 |
|--|--|
| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_alipay.jpb) | ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_wechat.png) |


## 有问题可以扫码加QQ群交流

Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class BaseFragment : RxFragment() {
protected fun initData(j: Int) {
mDrawableList.clear()
for (i in 0..j) {
val drawable = resources.getIdentifier("t$i", "drawable", mContext.packageName)
val drawable = resources.getIdentifier("bg_card$i", "drawable", mContext.packageName)
mDrawableList.add(drawable)
}
}
Expand Down
Binary file removed app/src/main/res/drawable-xxhdpi/t0.jpg
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/t1.jpg
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/t2.jpg
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/t3.jpg
Binary file not shown.
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/bg_card0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 实心 -->
<solid android:color="#CCFF99" />
<!-- 边框 -->
<!--<stroke
android:width="0.5dp"
android:color="#e35d5e" />-->
<!-- 圆角 -->
<corners android:radius="0dp" />
<!-- 边距 -->
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<!-- 渐变 -->
<!--<gradient
android:angle="270"
android:endColor="#FFFF782"
android:startColor="#13C7AF" />-->

</shape>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/bg_card1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 实心 -->
<solid android:color="#41F1E5" />
<!-- 边框 -->
<!--<stroke
android:width="0.5dp"
android:color="#e35d5e" />-->
<!-- 圆角 -->
<corners android:radius="0dp" />
<!-- 边距 -->
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<!-- 渐变 -->
<!--<gradient
android:angle="270"
android:endColor="#FFFF782"
android:startColor="#13C7AF" />-->

</shape>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/bg_card2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 实心 -->
<solid android:color="#8D41F1" />
<!-- 边框 -->
<!--<stroke
android:width="0.5dp"
android:color="#e35d5e" />-->
<!-- 圆角 -->
<corners android:radius="0dp" />
<!-- 边距 -->
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<!-- 渐变 -->
<!--<gradient
android:angle="270"
android:endColor="#FFFF782"
android:startColor="#13C7AF" />-->

</shape>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/bg_card3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 实心 -->
<solid android:color="#FF99CC" />
<!-- 边框 -->
<!--<stroke
android:width="0.5dp"
android:color="#e35d5e" />-->
<!-- 圆角 -->
<corners android:radius="0dp" />
<!-- 边距 -->
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<!-- 渐变 -->
<!--<gradient
android:angle="270"
android:endColor="#FFFF782"
android:startColor="#13C7AF" />-->

</shape>
57 changes: 48 additions & 9 deletions bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,57 @@ protected void onAttachedToWindow() {
// 触碰控件的时候,翻页应该停止,离开的时候如果之前是开启了翻页的话则重新启动翻页
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
int action = ev.getAction();
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_OUTSIDE) {
// 开始翻页
setLooping(false);
startLoop();
} else if (action == MotionEvent.ACTION_DOWN) {
// 停止翻页
setLooping(true);
stopLoop();
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_OUTSIDE:
setLooping(false);
startLoop();
break;
case MotionEvent.ACTION_DOWN:
setLooping(true);
stopLoop();
break;
}
return super.dispatchTouchEvent(ev);
}

// private int startX, startY;
// @Override
// public boolean dispatchTouchEvent(MotionEvent ev) {
// switch (ev.getAction()) {
// case MotionEvent.ACTION_DOWN:
// setLooping(true);
// stopLoop();
// startX = (int) ev.getX();
// startY = (int) ev.getY();
// getParent().requestDisallowInterceptTouchEvent(true);
// break;
// case MotionEvent.ACTION_MOVE:
// int endX = (int) ev.getX();
// int endY = (int) ev.getY();
// int disX = Math.abs(endX - startX);
// int disY = Math.abs(endY - startY);
// if (disX > disY) {
// getParent().requestDisallowInterceptTouchEvent(true);
// } else {
// getParent().requestDisallowInterceptTouchEvent(false);
// }
// break;
// case MotionEvent.ACTION_UP:
// case MotionEvent.ACTION_CANCEL:
// setLooping(false);
// startLoop();
// getParent().requestDisallowInterceptTouchEvent(false);
// break;
// case MotionEvent.ACTION_OUTSIDE:
// setLooping(false);
// startLoop();
// break;
// }
// return super.dispatchTouchEvent(ev);
// }

@Override
public void onPageSelected(int position) {
int size = mBannerPagerAdapter.getListSize();
Expand Down Expand Up @@ -247,6 +285,7 @@ private void setupViewPager(List<T> list) {
if (holderCreator == null) {
throw new NullPointerException("You must set HolderCreator for BannerViewPager");
}
currentPosition = 0;
if (list.size() > 0 && isCanLoop()) {
currentPosition = MAX_VALUE / 2 - ((MAX_VALUE / 2) % list.size()) + 1;
}
Expand Down
Binary file removed image/custom_indicator.gif
Binary file not shown.
Binary file modified image/page_style_multi.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/page_style_multi_overlay.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/page_style_multi_scale.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/pay_alipay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/pay_wechat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed image/preview1.gif
Binary file not shown.
Binary file removed image/preview2.gif
Binary file not shown.
Binary file removed image/preview3.gif
Binary file not shown.
Binary file modified image/qq_group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/qrcode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/slide_normal.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/slide_smooth.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/style_circle.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/style_custom1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/style_custom2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/style_custum.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/style_dash.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/style_round_rect.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2de297

Please sign in to comment.