Skip to content

Commit

Permalink
bug 修改
Browse files Browse the repository at this point in the history
Change-Id: I116f355616c3cda8d2ef29656ef7b68c15746e03
  • Loading branch information
youth5201314 committed Mar 27, 2020
1 parent 22c4624 commit 19cc1c5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
|setOrientation(@Orientation)|this|设置banner轮播方向(垂直or水平)
|setOnBannerListener(this)|this|设置点击事件,下标是从0开始
|addOnPageChangeListener(this)|this|添加viewpager2的滑动监听
|setPageTransformer|this|设置viewpager的切换效果
|setPageTransformer(PageTransformer)|this|设置viewpager的切换效果
|addPageTransformer(PageTransformer)|this|添加viewpager的切换效果(可以设置多个)
|removeIndicator()|this|移除设置的Indicator
|setIndicator(Indicator)|this|设置banner轮播指示器(提供有base和接口,可以自定义)
|setIndicatorSelectedColor(@ColorInt)|this|设置指示器选中颜色
|setIndicatorSelectedColorRes(@ColorRes)|this|设置指示器选中颜色
Expand All @@ -75,6 +77,7 @@
|setIndicatorSelectedWidth(int)|this|设置指示器选中的宽度
|setCustomIndicator(Indicator)|this|设置自定义指示器(配合布局文件,可以自我发挥)
|setBannerRound(float)|this|设置banner圆角(裁剪方式,需要5.0以上)
|setBannerGalleryEffect(int,int,float)|this|画廊效果(可设置间距缩放)

## Attributes属性
>在banner布局文件中调用,如果你自定义了indicator请做好兼容处理
Expand All @@ -84,8 +87,8 @@
|delay_time|integer|轮播间隔时间,默认3000
|is_auto_loop|boolean|是否自动轮播,默认true
|banner_orientation|enum|轮播方向:horizontal(默认) or vertical
|indicator_normal_width|dimension|指示器默认的宽度,默认6dp
|indicator_selected_width|dimension|指示器选中的宽度,默认8dp
|indicator_normal_width|dimension|指示器默认的宽度,默认5dp
|indicator_selected_width|dimension|指示器选中的宽度,默认7dp
|indicator_normal_color|color|指示器默认颜色,默认0x88ffffff
|indicator_selected_color|color|指示器选中颜色,默认0x88000000
|indicator_space|dimension|指示器之间的间距,默认6dp
Expand Down Expand Up @@ -266,9 +269,14 @@ public void onViewAttachedToWindow(BaseViewHolder holder) {



## 常见问题
## 常见问题(收录被反复询问的问题)

* 等使用一段时间在整理
* 网络图片加载不出来?

`banner本身不提供图片加载功能,首先确认banner本身使用是否正确,具体参考demo,
然后请检查你的图片加载框架或者网络请求框架,服务端也可能加了https安全认证,是看下是否报有证书相关错误`

* 怎么监控轮播过程的?


## Thanks
Expand All @@ -290,8 +298,9 @@ public void onViewAttachedToWindow(BaseViewHolder holder) {
* 修改banner内部轮播逻辑
* 增加设置画廊效果方法
* 内置有2种官方Transformer效果,更多效果你可以自定义
* 优化切换事件,去掉onBannerChanged
* 优化切换事件和点击事件,去掉onBannerChanged方法
* 新增轮播滑动时间控制,感谢zguop,这里的具体实现方法来自zguop的项目
* 支持多PageTransformer组合设置

#### v2.0.0-alpha03
banner 预览版使用中的问题优化。
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/test/banner/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
//添加画廊效果,可以参考我给的参数自己调试(不要和其他PageTransformer同时使用)
banner.setBannerGalleryEffect(25, 40, 0.14f);
banner.setDelayTime(2000);
banner.setUserInputEnabled(false);
// banner.setPageTransformer(new ZoomOutPageTransformer());
// banner.setPageTransformer(new DepthPageTransformer());

Expand Down
4 changes: 2 additions & 2 deletions banner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "2.0.0-alpha03"
version = "2.0.0-beta01"

android {
compileSdkVersion 29
Expand All @@ -11,7 +11,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 20003
versionCode 20004
versionName version
}
buildTypes {
Expand Down
21 changes: 13 additions & 8 deletions banner/src/main/java/com/youth/banner/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -172,9 +173,12 @@ private void initIndicatorAttr() {
}
}


@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (!getViewPager2().isUserInputEnabled()) {
return super.dispatchTouchEvent(ev);
}

int action = ev.getActionMasked();
if (action == MotionEvent.ACTION_UP
|| action == MotionEvent.ACTION_CANCEL
Expand Down Expand Up @@ -308,6 +312,13 @@ private void initIndicator() {
mIndicator.onPageChanged(getRealCount(), realPosition);
}


/**
* **********************************************************************
* ------------------------ 对外公开API ---------------------------------*
* **********************************************************************
*/

public void removeIndicator() {
if (mIndicator != null) {
removeView(mIndicator.getIndicatorView());
Expand All @@ -318,12 +329,6 @@ public long getScrollTime() {
return mScrollTime;
}

/**
* **********************************************************************
* ------------------------ 对外公开API ---------------------------------*
* **********************************************************************
*/

@NonNull
public BA getAdapter() {
if (mAdapter == null) {
Expand Down Expand Up @@ -387,7 +392,7 @@ public Banner setPageTransformer(@Nullable ViewPager2.PageTransformer transforme
return this;
}

public Banner removeTransformer(ViewPager2.PageTransformer transformer){
public Banner removeTransformer(ViewPager2.PageTransformer transformer) {
mCompositePageTransformer.removeTransformer(transformer);
return this;
}
Expand Down

0 comments on commit 19cc1c5

Please sign in to comment.