123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- package com.zhpan.bannerview.manager;
- import android.graphics.Path;
- import android.graphics.RectF;
- import android.view.View;
- import androidx.viewpager2.widget.ViewPager2;
- import com.zhpan.bannerview.constants.PageStyle;
- import com.zhpan.bannerview.utils.BannerUtils;
- import com.zhpan.indicator.enums.IndicatorOrientation;
- import com.zhpan.indicator.option.IndicatorOptions;
- import java.util.Arrays;
- import static com.zhpan.bannerview.transform.ScaleInTransformer.DEFAULT_MIN_SCALE;
- /**
- * <pre>
- * Created by zhpan on 2019/11/20.
- * Description:BannerViewPager的配置参数
- * </pre>
- */
- @SuppressWarnings("unused")
- public class BannerOptions {
- public BannerOptions() {
- mIndicatorOptions = new IndicatorOptions();
- pageMargin = BannerUtils.dp2px(20);
- rightRevealWidth = DEFAULT_REVEAL_WIDTH;
- leftRevealWidth = DEFAULT_REVEAL_WIDTH;
- roundRadius = new float[8];
- }
- public static final int DEFAULT_REVEAL_WIDTH = -1000;
- private int offScreenPageLimit = ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT;
- private int interval;
- private boolean isCanLoop;
- private boolean isAutoPlay = false;
- private int indicatorGravity;
- private int pageMargin;
- private int rightRevealWidth;
- private int leftRevealWidth;
- private int pageStyle = PageStyle.NORMAL;
- private float pageScale = DEFAULT_MIN_SCALE;
- private IndicatorMargin mIndicatorMargin;
- private int mIndicatorVisibility = View.VISIBLE;
- private int scrollDuration;
- private float[] roundRadius;
- private boolean userInputEnabled = true;
- private int orientation = ViewPager2.ORIENTATION_HORIZONTAL;
- private boolean rtl;
- private boolean disallowParentInterceptDownEvent;
- private final IndicatorOptions mIndicatorOptions;
- public int getInterval() {
- return interval;
- }
- public void setInterval(int interval) {
- this.interval = interval;
- }
- public boolean isCanLoop() {
- return isCanLoop;
- }
- public void setCanLoop(boolean canLoop) {
- isCanLoop = canLoop;
- }
- public boolean isAutoPlay() {
- return isAutoPlay;
- }
- public void setAutoPlay(boolean autoPlay) {
- isAutoPlay = autoPlay;
- }
- public int getIndicatorGravity() {
- return indicatorGravity;
- }
- public void setIndicatorGravity(int indicatorGravity) {
- this.indicatorGravity = indicatorGravity;
- }
- public int getIndicatorNormalColor() {
- return mIndicatorOptions.getNormalSliderColor();
- }
- public int getIndicatorCheckedColor() {
- return mIndicatorOptions.getCheckedSliderColor();
- }
- public int getNormalIndicatorWidth() {
- return (int) mIndicatorOptions.getNormalSliderWidth();
- }
- public void setIndicatorSliderColor(int normalColor, int checkedColor) {
- mIndicatorOptions.setSliderColor(normalColor, checkedColor);
- }
- public void setIndicatorSliderWidth(int normalWidth, int checkedWidth) {
- mIndicatorOptions.setSliderWidth(normalWidth, checkedWidth);
- }
- public int getCheckedIndicatorWidth() {
- return (int) mIndicatorOptions.getCheckedSliderWidth();
- }
- public IndicatorOptions getIndicatorOptions() {
- return mIndicatorOptions;
- }
- public int getPageMargin() {
- return pageMargin;
- }
- public void setPageMargin(int pageMargin) {
- this.pageMargin = pageMargin;
- }
- public int getRightRevealWidth() {
- return rightRevealWidth;
- }
- public void setRightRevealWidth(int rightRevealWidth) {
- this.rightRevealWidth = rightRevealWidth;
- }
- public int getLeftRevealWidth() {
- return leftRevealWidth;
- }
- public void setLeftRevealWidth(int leftRevealWidth) {
- this.leftRevealWidth = leftRevealWidth;
- }
- public int getIndicatorStyle() {
- return mIndicatorOptions.getIndicatorStyle();
- }
- public void setIndicatorStyle(int indicatorStyle) {
- mIndicatorOptions.setIndicatorStyle(indicatorStyle);
- }
- public int getIndicatorSlideMode() {
- return mIndicatorOptions.getSlideMode();
- }
- public void setIndicatorSlideMode(int indicatorSlideMode) {
- mIndicatorOptions.setSlideMode(indicatorSlideMode);
- }
- public float getIndicatorGap() {
- return mIndicatorOptions.getSliderGap();
- }
- public void setIndicatorGap(float indicatorGap) {
- mIndicatorOptions.setSliderGap(indicatorGap);
- }
- public float getIndicatorHeight() {
- return mIndicatorOptions.getSliderHeight();
- }
- public void setIndicatorHeight(int indicatorHeight) {
- mIndicatorOptions.setSliderHeight(indicatorHeight);
- }
- public int getPageStyle() {
- return pageStyle;
- }
- public void setPageStyle(int pageStyle) {
- this.pageStyle = pageStyle;
- }
- public float getPageScale() {
- return pageScale;
- }
- public void setPageScale(float pageScale) {
- this.pageScale = pageScale;
- }
- public IndicatorMargin getIndicatorMargin() {
- return mIndicatorMargin;
- }
- public void setIndicatorMargin(int left, int top, int right, int bottom) {
- mIndicatorMargin = new IndicatorMargin(left, top, right, bottom);
- }
- public float[] getRoundRectRadius() {
- return roundRadius;
- }
- public void setRoundRectRadius(int radius) {
- setRoundRectRadius(radius, radius, radius, radius);
- }
- public void setRoundRectRadius(int topLeftRadius, int topRightRadius, int bottomLeftRadius,
- int bottomRightRadius) {
- roundRadius[0] = topLeftRadius;
- roundRadius[1] = topLeftRadius;
- roundRadius[2] = topRightRadius;
- roundRadius[3] = topRightRadius;
- roundRadius[4] = bottomRightRadius;
- roundRadius[5] = bottomRightRadius;
- roundRadius[6] = bottomLeftRadius;
- roundRadius[7] = bottomLeftRadius;
- }
- public int getScrollDuration() {
- return scrollDuration;
- }
- public void setScrollDuration(int scrollDuration) {
- this.scrollDuration = scrollDuration;
- }
- public int getIndicatorVisibility() {
- return mIndicatorVisibility;
- }
- public void setIndicatorVisibility(int indicatorVisibility) {
- mIndicatorVisibility = indicatorVisibility;
- }
- public int getOrientation() {
- return orientation;
- }
- public void setOrientation(int orientation) {
- this.orientation = orientation;
- mIndicatorOptions.setOrientation(orientation);
- }
- public boolean isUserInputEnabled() {
- return userInputEnabled;
- }
- public void setUserInputEnabled(boolean userInputEnabled) {
- this.userInputEnabled = userInputEnabled;
- }
- public void resetIndicatorOptions() {
- mIndicatorOptions.setCurrentPosition(0);
- mIndicatorOptions.setSlideProgress(0);
- }
- public boolean isDisallowParentInterceptDownEvent() {
- return disallowParentInterceptDownEvent;
- }
- public void setDisallowParentInterceptDownEvent(boolean disallowParentInterceptDownEvent) {
- this.disallowParentInterceptDownEvent = disallowParentInterceptDownEvent;
- }
- public int getOffScreenPageLimit() {
- return offScreenPageLimit;
- }
- public void setOffScreenPageLimit(int offScreenPageLimit) {
- this.offScreenPageLimit = offScreenPageLimit;
- }
- public boolean isRtl() {
- return rtl;
- }
- public void setRtl(boolean rtl) {
- this.rtl = rtl;
- mIndicatorOptions.setOrientation(rtl ? IndicatorOrientation.INDICATOR_RTL : IndicatorOrientation.INDICATOR_HORIZONTAL);
- }
- public static class IndicatorMargin {
- private final int left, right, top, bottom;
- public IndicatorMargin(int left, int top, int right, int bottom) {
- this.left = left;
- this.right = right;
- this.top = top;
- this.bottom = bottom;
- }
- public int getLeft() {
- return left;
- }
- public int getRight() {
- return right;
- }
- public int getTop() {
- return top;
- }
- public int getBottom() {
- return bottom;
- }
- }
- }
|