diff --git a/README.md b/README.md index 0544202c..487a2a31 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ BannerViewPager supports three Indicator Styles and three Indicator Slide mode n | NORMAL| ![CIRCLE_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_normal.gif) | ![DASH_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_normal.gif) | ![ROUND_RECT_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_normal.gif) | | SMOOTH| ![CIRCLE_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_smooth.gif) | ![DASH_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_smooth.gif) | ![ROUND_RECT_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_smooth.gif) | | WORM| ![CIRCLE_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_worm.gif) | ![DASH_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_worm.gif) | ![ROUND_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_worm.gif) | +| COLOR| ![CIRCLE_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_color.gif) | ![DASH_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_color.gif) | ![ROUND_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_color.gif) | +| SCALE| ![CIRCLE_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_scale.gif) | ![DASH_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_scale.gif) | ![ROUND_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_scale.gif) | #### (2)Custom Indicator @@ -179,7 +181,6 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion' android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:background="#66000000" android:gravity="center_vertical"> { mBannerViewPager = findViewById(R.id.banner_view); mViewPager .setAutoPlay(true) + .setScrollDuration(800) .setIndicatorStyle(IndicatorStyle.ROUND_RECT) .setIndicatorSliderGap(getResources().getDimensionPixelOffset(R.dimen.dp_4)) .setIndicatorSliderWidth(getResources().getDimensionPixelOffset(R.dimen.dp_4), getResources().getDimensionPixelOffset(R.dimen.dp_10)) diff --git a/README_CN.md b/README_CN.md index 59a935da..f8ce631b 100644 --- a/README_CN.md +++ b/README_CN.md @@ -54,6 +54,8 @@ BannerViewPager目前已支持三种IndicatorViewStyle,以及三种IndicatorSlid | NORMAL| ![CIRCLE_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_normal.gif) | ![DASH_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_normal.gif) | ![ROUND_RECT_NORMAL](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_normal.gif) | | SMOOTH| ![CIRCLE_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_smooth.gif) | ![DASH_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_smooth.gif) | ![ROUND_RECT_SMOOTH](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_smooth.gif) | | WORM| ![CIRCLE_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_worm.gif) | ![DASH_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_worm.gif) | ![ROUND_WORM](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_worm.gif) | +| COLOR| ![CIRCLE_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_color.gif) | ![DASH_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_color.gif) | ![ROUND_COLOR](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_color.gif) | +| SCALE| ![CIRCLE_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/slide_circle_scale.gif) | ![DASH_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_dash_scale.gif) | ![ROUND_SCALE](https://github.com/zhpanvip/Resource/blob/master/image/indicator/style_round_rect_scale.gif) | #### (2)Custom Indicator @@ -177,7 +179,6 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion' android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:background="#66000000" android:gravity="center_vertical"> { mViewPager = findViewById(R.id.banner_view); mViewPager .setAutoPlay(true) + .setScrollDuration(800) .setIndicatorStyle(IndicatorStyle.ROUND_RECT) .setIndicatorSliderGap(getResources().getDimensionPixelOffset(R.dimen.dp_4)) .setIndicatorSliderWidth(getResources().getDimensionPixelOffset(R.dimen.dp_4), getResources().getDimensionPixelOffset(R.dimen.dp_10)) diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 0adf0894..22ce3a42 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/HomeFragment.java b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/HomeFragment.java index 03219b12..5a259eca 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/HomeFragment.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/HomeFragment.java @@ -52,6 +52,7 @@ public class HomeFragment extends BaseFragment { private IndicatorView mIndicatorView; private TextView mTvTitle; private RelativeLayout mRlIndicator; + private View headerView; @Override protected int getLayout() { @@ -103,7 +104,7 @@ public static HomeFragment getInstance() { private void initRecyclerView(View view) { recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getMContext())); - recyclerView.addHeadView(getHeaderView(),true); + recyclerView.addHeadView(getHeaderView(), true); recyclerView.addItemDecoration(new DividerItemDecoration(getMContext(), DividerItemDecoration.VERTICAL)); articleAdapter = new ArticleAdapter(getMContext(), new ArrayList<>()); @@ -124,6 +125,7 @@ private void fetchData(boolean showLoading) { .subscribe(new ResponseObserver() { @Override public void onSuccess(DataWrapper response) { + headerView.setVisibility(View.VISIBLE); List dataList = response.getDataBeanList(); BannerData bannerData = new BannerData(); bannerData.setDrawable(R.drawable.bg_card0); @@ -165,6 +167,7 @@ private void initBanner() { mViewPagerHorizontal .setAutoPlay(true) .setScrollDuration(600) + .setIndicatorStyle(IndicatorStyle.CIRCLE) .setIndicatorSlideMode(IndicatorSlideMode.WORM) .setInterval(3000) .setIndicatorGravity(IndicatorGravity.END) @@ -186,6 +189,7 @@ public void onPageSelected(int position) { .setAutoPlay(true) .setScrollDuration(500) .setIndicatorStyle(IndicatorStyle.ROUND_RECT) + .setIndicatorSlideMode(IndicatorSlideMode.SCALE) .setIndicatorSliderGap(getResources().getDimensionPixelOffset(R.dimen.dp_4)) .setIndicatorSliderWidth(getResources().getDimensionPixelOffset(R.dimen.dp_4), getResources().getDimensionPixelOffset(R.dimen.dp_10)) .setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color)) @@ -200,7 +204,7 @@ private void onPageClicked(int position) { } private View getHeaderView() { - View headerView = LayoutInflater.from(getMContext()).inflate(R.layout.item_header_view, recyclerView, false); + headerView = LayoutInflater.from(getMContext()).inflate(R.layout.item_header_view, recyclerView, false); mRlIndicator = headerView.findViewById(R.id.layout_indicator); mViewPagerHorizontal = headerView.findViewById(R.id.banner_view); mViewPagerVertical = headerView.findViewById(R.id.banner_view2); diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java index 2e70944e..5a73e34e 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java @@ -66,6 +66,7 @@ protected void initView(Bundle savedInstanceState, View view) { mRadioGroupMode = view.findViewById(R.id.rg_slide_mode); mViewPager = view.findViewById(R.id.banner_view); mViewPager.setIndicatorSliderGap(BannerUtils.dp2px(6)) + .setScrollDuration(800) .setAdapter(new ImageResourceAdapter(0)) .setRoundCorner(BannerUtils.dp2px(6)); initRadioGroup(); @@ -86,6 +87,12 @@ private void initRadioGroup() { case R.id.rb_smooth: mSlideMode = IndicatorSlideMode.SMOOTH; break; + case R.id.rb_color: + mSlideMode = IndicatorSlideMode.COLOR; + break; + case R.id.rb_scale: + mSlideMode = IndicatorSlideMode.SCALE; + break; } checkedChange(mCheckId); }); @@ -102,23 +109,9 @@ private void checkedChange(int checkedId) { case R.id.rb_round_rect: setupRoundRectIndicator(); break; - case R.id.rb_tmall: - setupTMallIndicator(); - break; } } - private void setupTMallIndicator() { - mViewPager - .setIndicatorStyle(IndicatorStyle.DASH) - .setIndicatorSliderGap(0) - .setIndicatorSlideMode(mSlideMode) - .setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color)) - .setIndicatorSliderWidth(getResources().getDimensionPixelOffset(R.dimen.dp_15)) - .setIndicatorHeight(getResources().getDimensionPixelOffset(R.dimen.dp_3)) - .create(getPicList(4)); - } - private void setupRoundRectIndicator() { int checkedWidth = getResources().getDimensionPixelOffset(R.dimen.dp_10); int normalWidth = getNormalWidth(); @@ -133,14 +126,23 @@ private void setupRoundRectIndicator() { } private void setupCircleIndicator() { + int checkedWidth; + int normalWidth; + if (mSlideMode == IndicatorSlideMode.SCALE) { + checkedWidth = getResources().getDimensionPixelOffset(R.dimen.dp_5); + normalWidth = getResources().getDimensionPixelOffset(R.dimen.dp_3); + } else { + checkedWidth = getResources().getDimensionPixelOffset(R.dimen.dp_4); + normalWidth = checkedWidth; + } + mViewPager.setIndicatorStyle(IndicatorStyle.CIRCLE) .setIndicatorSlideMode(mSlideMode) .setIndicatorGravity(IndicatorGravity.CENTER) .setIndicatorSliderGap(getResources().getDimensionPixelOffset(R.dimen.dp_6)) - .setIndicatorHeight(getResources().getDimensionPixelOffset(R.dimen.dp_4)) + .setIndicatorSliderRadius(normalWidth, checkedWidth) .setOnPageClickListener(position -> ToastUtils.show("position:" + position)) - .setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color)) - .setIndicatorSliderRadius(getResources().getDimensionPixelOffset(R.dimen.dp_4)).create(getPicList(4)); + .setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color)).create(getPicList(4)); } private void setupDashIndicator() { @@ -157,7 +159,8 @@ private void setupDashIndicator() { } private int getNormalWidth() { - if (mSlideMode == IndicatorSlideMode.SMOOTH || mSlideMode == IndicatorSlideMode.WORM) { + if (mSlideMode == IndicatorSlideMode.SMOOTH || mSlideMode == IndicatorSlideMode.WORM + || mSlideMode == IndicatorSlideMode.COLOR) { return getResources().getDimensionPixelOffset(R.dimen.dp_10); } else { return getResources().getDimensionPixelOffset(R.dimen.dp_4); diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java index f9ad9914..e44e79d8 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java @@ -117,7 +117,7 @@ private void setDrawableIndicator(IIndicator indicator) { .setIndicatorSlideMode(IndicatorSlideMode.NORMAL) .setIndicatorVisibility(View.VISIBLE) .setIndicatorGravity(IndicatorGravity.CENTER) - .create(getPicList(4)); + .create(getMDrawableList()); } private IIndicator getDrawableIndicator() { diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/PageFragment.java b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/PageFragment.java index 8b78c628..a0e88695 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/fragment/PageFragment.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/fragment/PageFragment.java @@ -60,7 +60,7 @@ protected void initView(Bundle savedInstanceState, View view) { mRadioGroupPageStyle = view.findViewById(R.id.rg_page_style); radioButton = view.findViewById(R.id.rb_multi_page); mViewPager - .setIndicatorSlideMode(IndicatorSlideMode.NORMAL) + .setIndicatorSlideMode(IndicatorSlideMode.SCALE) .setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color)) .setIndicatorSliderRadius(getResources().getDimensionPixelOffset(R.dimen.dp_4), getResources().getDimensionPixelOffset(R.dimen.dp_5)) .setOnPageClickListener(position -> ToastUtils.show("position:" + position)) diff --git a/app/src/main/res/layout/fragment_indicator.xml b/app/src/main/res/layout/fragment_indicator.xml index 8f17b4b7..5c8baf33 100644 --- a/app/src/main/res/layout/fragment_indicator.xml +++ b/app/src/main/res/layout/fragment_indicator.xml @@ -67,15 +67,6 @@ android:text="ROUND_RECT" android:textSize="@dimen/sp_16" /> - - @@ -116,14 +107,13 @@ android:text="WORM" android:textSize="@dimen/sp_16" /> - + android:textSize="@dimen/sp_16" /> + + + diff --git a/app/src/main/res/layout/item_header_view.xml b/app/src/main/res/layout/item_header_view.xml index 6b70bf06..c75a4c10 100644 --- a/app/src/main/res/layout/item_header_view.xml +++ b/app/src/main/res/layout/item_header_view.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:visibility="gone" android:orientation="vertical"> list) { - BannerOptions bannerOptions = mBannerManager.bannerOptions(); + BannerOptions bannerOptions = mBannerManager.getBannerOptions(); bannerOptions.resetIndicatorOptions(); if (isCustomIndicator && null != mIndicatorView) { initIndicator(mIndicatorView); @@ -283,7 +283,7 @@ private void setIndicatorValues(List list) { } private void initIndicator(IIndicator indicatorView) { - mIndicatorLayout.setVisibility(mBannerManager.bannerOptions().getIndicatorVisibility()); + mIndicatorLayout.setVisibility(mBannerManager.getBannerOptions().getIndicatorVisibility()); mIndicatorView = indicatorView; if (((View) mIndicatorView).getParent() == null) { mIndicatorLayout.removeAllViews(); @@ -296,7 +296,7 @@ private void initIndicator(IIndicator indicatorView) { private void initIndicatorGravity() { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) ((View) mIndicatorView).getLayoutParams(); - switch (mBannerManager.bannerOptions().getIndicatorGravity()) { + switch (mBannerManager.getBannerOptions().getIndicatorGravity()) { case CENTER: layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); break; @@ -311,7 +311,7 @@ private void initIndicatorGravity() { private void initIndicatorViewMargin() { ViewGroup.MarginLayoutParams layoutParams = (MarginLayoutParams) ((View) mIndicatorView).getLayoutParams(); - BannerOptions.IndicatorMargin indicatorMargin = mBannerManager.bannerOptions().getIndicatorMargin(); + BannerOptions.IndicatorMargin indicatorMargin = mBannerManager.getBannerOptions().getIndicatorMargin(); if (indicatorMargin == null) { int dp10 = BannerUtils.dp2px(10); layoutParams.setMargins(dp10, dp10, dp10, dp10); @@ -322,7 +322,7 @@ private void initIndicatorViewMargin() { } private void initRoundCorner() { - int roundCorner = mBannerManager.bannerOptions().getRoundRectRadius(); + int roundCorner = mBannerManager.getBannerOptions().getRoundRectRadius(); if (roundCorner > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewStyleSetter viewStyleSetter = new ViewStyleSetter(this); viewStyleSetter.setRoundRect(roundCorner); @@ -333,7 +333,7 @@ private void setupViewPager(List list) { if (mBannerPagerAdapter == null) { throw new NullPointerException("You must set adapter for BannerViewPager"); } - BannerOptions bannerOptions = mBannerManager.bannerOptions(); + BannerOptions bannerOptions = mBannerManager.getBannerOptions(); if (bannerOptions.getScrollDuration() != 0) ScrollDurationManger.reflectLayoutManager(mViewPager, bannerOptions.getScrollDuration()); currentPosition = 0; @@ -353,22 +353,22 @@ private void setupViewPager(List list) { } private void initPageStyle() { - switch (mBannerManager.bannerOptions().getPageStyle()) { + switch (mBannerManager.getBannerOptions().getPageStyle()) { case PageStyle.MULTI_PAGE: setMultiPageStyle(false, MAX_SCALE); break; case PageStyle.MULTI_PAGE_OVERLAP: - setMultiPageStyle(true, mBannerManager.bannerOptions().getPageScale()); + setMultiPageStyle(true, mBannerManager.getBannerOptions().getPageScale()); break; case PageStyle.MULTI_PAGE_SCALE: - setMultiPageStyle(false, mBannerManager.bannerOptions().getPageScale()); + setMultiPageStyle(false, mBannerManager.getBannerOptions().getPageScale()); break; } } private void setMultiPageStyle(boolean overlap, float scale) { RecyclerView recyclerView = (RecyclerView) mViewPager.getChildAt(0); - BannerOptions bannerOptions = mBannerManager.bannerOptions(); + BannerOptions bannerOptions = mBannerManager.getBannerOptions(); int orientation = bannerOptions.getOrientation(); int padding = bannerOptions.getPageMargin() + bannerOptions.getRevealWidth(); if (orientation == ViewPager2.ORIENTATION_HORIZONTAL) @@ -389,15 +389,15 @@ else if (orientation == ViewPager2.ORIENTATION_VERTICAL) { } private int getInterval() { - return mBannerManager.bannerOptions().getInterval(); + return mBannerManager.getBannerOptions().getInterval(); } private boolean isAutoPlay() { - return mBannerManager.bannerOptions().isAutoPlay(); + return mBannerManager.getBannerOptions().isAutoPlay(); } private boolean isCanLoop() { - return mBannerManager.bannerOptions().isCanLoop(); + return mBannerManager.getBannerOptions().isCanLoop(); } /** @@ -445,7 +445,7 @@ public BaseBannerAdapter getAdapter() { * @param radius round radius */ public BannerViewPager setRoundCorner(int radius) { - mBannerManager.bannerOptions().setRoundRectRadius(radius); + mBannerManager.getBannerOptions().setRoundRectRadius(radius); return this; } @@ -467,9 +467,9 @@ public BannerViewPager setRoundRect(int radius) { * @param autoPlay is enable auto play */ public BannerViewPager setAutoPlay(boolean autoPlay) { - mBannerManager.bannerOptions().setAutoPlay(autoPlay); + mBannerManager.getBannerOptions().setAutoPlay(autoPlay); if (isAutoPlay()) { - mBannerManager.bannerOptions().setCanLoop(true); + mBannerManager.getBannerOptions().setCanLoop(true); } return this; } @@ -480,9 +480,9 @@ public BannerViewPager setAutoPlay(boolean autoPlay) { * @param canLoop is can loop */ public BannerViewPager setCanLoop(boolean canLoop) { - mBannerManager.bannerOptions().setCanLoop(canLoop); + mBannerManager.getBannerOptions().setCanLoop(canLoop); if (!canLoop) { - mBannerManager.bannerOptions().setAutoPlay(false); + mBannerManager.getBannerOptions().setAutoPlay(false); } return this; } @@ -493,7 +493,7 @@ public BannerViewPager setCanLoop(boolean canLoop) { * @param interval loop interval,unit is millisecond. */ public BannerViewPager setInterval(int interval) { - mBannerManager.bannerOptions().setInterval(interval); + mBannerManager.getBannerOptions().setInterval(interval); return this; } @@ -529,7 +529,7 @@ public void removeTransformer(@Nullable ViewPager2.PageTransformer transformer) * @param pageMargin page margin */ public BannerViewPager setPageMargin(int pageMargin) { - mBannerManager.bannerOptions().setPageMargin(pageMargin); + mBannerManager.getBannerOptions().setPageMargin(pageMargin); if (mMarginPageTransformer != null) { mCompositePageTransformer.removeTransformer(mMarginPageTransformer); } @@ -555,7 +555,7 @@ public BannerViewPager setOnPageClickListener(OnPageClickListener onPageC * @param scrollDuration page scroll duration */ public BannerViewPager setScrollDuration(int scrollDuration) { - mBannerManager.bannerOptions().setScrollDuration(scrollDuration); + mBannerManager.getBannerOptions().setScrollDuration(scrollDuration); return this; } @@ -567,7 +567,7 @@ public BannerViewPager setScrollDuration(int scrollDuration) { */ public BannerViewPager setIndicatorSliderColor(@ColorInt int normalColor, @ColorInt int checkedColor) { - mBannerManager.bannerOptions().setIndicatorSliderColor(normalColor, checkedColor); + mBannerManager.getBannerOptions().setIndicatorSliderColor(normalColor, checkedColor); return this; } @@ -594,7 +594,7 @@ public BannerViewPager setIndicatorSliderRadius(int radius) { * @param checkedRadius checked circle radius */ public BannerViewPager setIndicatorSliderRadius(int normalRadius, int checkedRadius) { - mBannerManager.bannerOptions().setIndicatorSliderWidth(normalRadius * 2, checkedRadius * 2); + mBannerManager.getBannerOptions().setIndicatorSliderWidth(normalRadius * 2, checkedRadius * 2); return this; } @@ -615,12 +615,12 @@ public BannerViewPager setIndicatorSliderWidth(int indicatorWidth) { * if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#CIRCLE } means checked circle diameter */ public BannerViewPager setIndicatorSliderWidth(int normalWidth, int checkWidth) { - mBannerManager.bannerOptions().setIndicatorSliderWidth(normalWidth, checkWidth); + mBannerManager.getBannerOptions().setIndicatorSliderWidth(normalWidth, checkWidth); return this; } public BannerViewPager setIndicatorHeight(int indicatorHeight) { - mBannerManager.bannerOptions().setIndicatorHeight(indicatorHeight); + mBannerManager.getBannerOptions().setIndicatorHeight(indicatorHeight); return this; } @@ -630,7 +630,7 @@ public BannerViewPager setIndicatorHeight(int indicatorHeight) { * @param indicatorGap indicator gap */ public BannerViewPager setIndicatorSliderGap(int indicatorGap) { - mBannerManager.bannerOptions().setIndicatorGap(indicatorGap); + mBannerManager.getBannerOptions().setIndicatorGap(indicatorGap); return this; } @@ -640,7 +640,7 @@ public BannerViewPager setIndicatorSliderGap(int indicatorGap) { * @param visibility One of {@link View#VISIBLE}, {@link View#INVISIBLE}, or {@link View#GONE}. */ public BannerViewPager setIndicatorVisibility(@Visibility int visibility) { - mBannerManager.bannerOptions().setIndicatorVisibility(visibility); + mBannerManager.getBannerOptions().setIndicatorVisibility(visibility); return this; } @@ -653,7 +653,7 @@ public BannerViewPager setIndicatorVisibility(@Visibility int visibility) * {@link com.zhpan.bannerview.constants.IndicatorGravity#END} */ public BannerViewPager setIndicatorGravity(@AIndicatorGravity int gravity) { - mBannerManager.bannerOptions().setIndicatorGravity(gravity); + mBannerManager.getBannerOptions().setIndicatorGravity(gravity); return this; } @@ -665,7 +665,7 @@ public BannerViewPager setIndicatorGravity(@AIndicatorGravity int gravity * @see com.zhpan.indicator.enums.IndicatorSlideMode#SMOOTH */ public BannerViewPager setIndicatorSlideMode(@AIndicatorSlideMode int slideMode) { - mBannerManager.bannerOptions().setIndicatorSlideMode(slideMode); + mBannerManager.getBannerOptions().setIndicatorSlideMode(slideMode); return this; } @@ -693,7 +693,7 @@ public BannerViewPager setIndicatorView(IIndicator customIndicator) { * @see com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT */ public BannerViewPager setIndicatorStyle(@AIndicatorStyle int indicatorStyle) { - mBannerManager.bannerOptions().setIndicatorStyle(indicatorStyle); + mBannerManager.getBannerOptions().setIndicatorStyle(indicatorStyle); return this; } @@ -712,7 +712,7 @@ public void create(List data) { * {@link androidx.viewpager2.widget.ViewPager2#ORIENTATION_VERTICAL} */ public BannerViewPager setOrientation(@ViewPager2.Orientation int orientation) { - mBannerManager.bannerOptions().setOrientation(orientation); + mBannerManager.getBannerOptions().setOrientation(orientation); return this; } @@ -771,8 +771,8 @@ public BannerViewPager setPageStyle(@APageStyle int pageStyle) { } public BannerViewPager setPageStyle(@APageStyle int pageStyle, float pageScale) { - mBannerManager.bannerOptions().setPageStyle(pageStyle); - mBannerManager.bannerOptions().setPageScale(pageScale); + mBannerManager.getBannerOptions().setPageStyle(pageStyle); + mBannerManager.getBannerOptions().setPageScale(pageScale); return this; } @@ -781,7 +781,7 @@ public BannerViewPager setPageStyle(@APageStyle int pageStyle, float page * @param revealWidth 一屏多页模式下两边页面显露出来的宽度 */ public BannerViewPager setRevealWidth(int revealWidth) { - mBannerManager.bannerOptions().setRevealWidth(revealWidth); + mBannerManager.getBannerOptions().setRevealWidth(revealWidth); return this; } @@ -789,18 +789,18 @@ public BannerViewPager setRevealWidth(int revealWidth) { * 建议使用默认的offScreenPageLimit */ public BannerViewPager setOffScreenPageLimit(int offScreenPageLimit) { - mBannerManager.bannerOptions().setOffScreenPageLimit(offScreenPageLimit); + mBannerManager.getBannerOptions().setOffScreenPageLimit(offScreenPageLimit); return this; } public BannerViewPager setIndicatorMargin(int left, int top, int right, int bottom) { - mBannerManager.bannerOptions().setIndicatorMargin(left, top, right, bottom); + mBannerManager.getBannerOptions().setIndicatorMargin(left, top, right, bottom); return this; } public BannerViewPager setUserInputEnabled(boolean userInputEnabled) { - mBannerManager.bannerOptions().setUserInputEnabled(userInputEnabled); + mBannerManager.getBannerOptions().setUserInputEnabled(userInputEnabled); return this; } @@ -828,7 +828,7 @@ public BannerViewPager showIndicator(boolean showIndicator) { */ @Deprecated public BannerViewPager disableTouchScroll(boolean disableTouchScroll) { - mBannerManager.bannerOptions().setUserInputEnabled(!disableTouchScroll); + mBannerManager.getBannerOptions().setUserInputEnabled(!disableTouchScroll); return this; } diff --git a/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerManager.java b/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerManager.java index 571fcdd1..c9ddf757 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerManager.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerManager.java @@ -20,7 +20,7 @@ public BannerManager() { mAttributeController = new AttributeController(mBannerOptions); } - public BannerOptions bannerOptions() { + public BannerOptions getBannerOptions() { if (mBannerOptions == null) { mBannerOptions = new BannerOptions(); } diff --git a/bannerview/src/main/res/values/attrs.xml b/bannerview/src/main/res/values/attrs.xml index 6316784b..5ce596e8 100644 --- a/bannerview/src/main/res/values/attrs.xml +++ b/bannerview/src/main/res/values/attrs.xml @@ -6,14 +6,12 @@ - - @@ -23,6 +21,8 @@ + + @@ -35,7 +35,6 @@ - diff --git a/settings.gradle b/settings.gradle index f28b0a54..0d5997f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,3 @@ include ':app', ':bannerview', ':ideahttp' +//include "indicator" +//project(':indicator').projectDir = file('../viewpagerindicator/indicator') \ No newline at end of file