1fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas/*
2fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * Copyright (C) 2013 The Android Open Source Project
3fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas *
4fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * Licensed under the Apache License, Version 2.0 (the "License");
5fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * you may not use this file except in compliance with the License.
6fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * You may obtain a copy of the License at
7fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas *
8fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas *      http://www.apache.org/licenses/LICENSE-2.0
9fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas *
10fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * Unless required by applicable law or agreed to in writing, software
11fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * distributed under the License is distributed on an "AS IS" BASIS,
12fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * See the License for the specific language governing permissions and
14fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas * limitations under the License.
15fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas */
16fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
17fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucaspackage com.example.android.common.view;
18fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
19fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.R;
20fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.content.Context;
21fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.graphics.Canvas;
22fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.graphics.Color;
23fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.graphics.Paint;
24fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.util.AttributeSet;
25fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.util.TypedValue;
26fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.view.View;
27fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasimport android.widget.LinearLayout;
28fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
29fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucasclass SlidingTabStrip extends LinearLayout {
30fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
31fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 2;
32fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
33fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 8;
34fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;
35fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
36fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final int DEFAULT_DIVIDER_THICKNESS_DIPS = 1;
37fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final byte DEFAULT_DIVIDER_COLOR_ALPHA = 0x20;
38fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static final float DEFAULT_DIVIDER_HEIGHT = 0.5f;
39fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
40fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final int mBottomBorderThickness;
41fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final Paint mBottomBorderPaint;
42fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
43fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final int mSelectedIndicatorThickness;
44fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final Paint mSelectedIndicatorPaint;
45fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
46fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final int mDefaultBottomBorderColor;
47fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
48fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final Paint mDividerPaint;
49fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final float mDividerHeight;
50fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
51fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private int mSelectedPosition;
52fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private float mSelectionOffset;
53fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
54fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private SlidingTabLayout.TabColorizer mCustomTabColorizer;
55fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private final SimpleTabColorizer mDefaultTabColorizer;
56fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
57fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    SlidingTabStrip(Context context) {
58fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        this(context, null);
59fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
60fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
61fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    SlidingTabStrip(Context context, AttributeSet attrs) {
62fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        super(context, attrs);
63fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        setWillNotDraw(false);
64fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
65fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final float density = getResources().getDisplayMetrics().density;
66fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
67fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        TypedValue outValue = new TypedValue();
68fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        context.getTheme().resolveAttribute(R.attr.colorForeground, outValue, true);
69fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final int themeForegroundColor =  outValue.data;
70fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
71fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor,
72fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);
73fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
74fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultTabColorizer = new SimpleTabColorizer();
75fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR);
76fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultTabColorizer.setDividerColors(setColorAlpha(themeForegroundColor,
77fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                DEFAULT_DIVIDER_COLOR_ALPHA));
78fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
79fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
80fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mBottomBorderPaint = new Paint();
81fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mBottomBorderPaint.setColor(mDefaultBottomBorderColor);
82fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
83fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density);
84fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mSelectedIndicatorPaint = new Paint();
85fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
86fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDividerHeight = DEFAULT_DIVIDER_HEIGHT;
87fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDividerPaint = new Paint();
88fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDividerPaint.setStrokeWidth((int) (DEFAULT_DIVIDER_THICKNESS_DIPS * density));
89fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
90fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
91fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    void setCustomTabColorizer(SlidingTabLayout.TabColorizer customTabColorizer) {
92fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mCustomTabColorizer = customTabColorizer;
93fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        invalidate();
94fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
95fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
96fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    void setSelectedIndicatorColors(int... colors) {
97fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        // Make sure that the custom colorizer is removed
98fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mCustomTabColorizer = null;
99fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultTabColorizer.setIndicatorColors(colors);
100fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        invalidate();
101fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
102fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
103fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    void setDividerColors(int... colors) {
104fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        // Make sure that the custom colorizer is removed
105fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mCustomTabColorizer = null;
106fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mDefaultTabColorizer.setDividerColors(colors);
107fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        invalidate();
108fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
109fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
110fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    void onViewPagerPageChanged(int position, float positionOffset) {
111fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mSelectedPosition = position;
112fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        mSelectionOffset = positionOffset;
113fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        invalidate();
114fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
115fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
116fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    @Override
117fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    protected void onDraw(Canvas canvas) {
118fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final int height = getHeight();
119fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final int childCount = getChildCount();
120fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final int dividerHeightPx = (int) (Math.min(Math.max(0f, mDividerHeight), 1f) * height);
121fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final SlidingTabLayout.TabColorizer tabColorizer = mCustomTabColorizer != null
122fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                ? mCustomTabColorizer
123fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                : mDefaultTabColorizer;
124fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
125fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        // Thick colored underline below the current selection
126fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        if (childCount > 0) {
127fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            View selectedTitle = getChildAt(mSelectedPosition);
128fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            int left = selectedTitle.getLeft();
129fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            int right = selectedTitle.getRight();
130fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            int color = tabColorizer.getIndicatorColor(mSelectedPosition);
131fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
132fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) {
133fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                int nextColor = tabColorizer.getIndicatorColor(mSelectedPosition + 1);
134fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                if (color != nextColor) {
135fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                    color = blendColors(nextColor, color, mSelectionOffset);
136fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                }
137fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
138fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                // Draw the selection partway between the tabs
139fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                View nextTitle = getChildAt(mSelectedPosition + 1);
140fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                left = (int) (mSelectionOffset * nextTitle.getLeft() +
141fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                        (1.0f - mSelectionOffset) * left);
142fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                right = (int) (mSelectionOffset * nextTitle.getRight() +
143fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                        (1.0f - mSelectionOffset) * right);
144fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            }
145fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
146fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            mSelectedIndicatorPaint.setColor(color);
147fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
148fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            canvas.drawRect(left, height - mSelectedIndicatorThickness, right,
149fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                    height, mSelectedIndicatorPaint);
150fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
151fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
152fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        // Thin underline along the entire bottom edge
153fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        canvas.drawRect(0, height - mBottomBorderThickness, getWidth(), height, mBottomBorderPaint);
154fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
155fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        // Vertical separators between the titles
156fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        int separatorTop = (height - dividerHeightPx) / 2;
157fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        for (int i = 0; i < childCount - 1; i++) {
158fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            View child = getChildAt(i);
159fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            mDividerPaint.setColor(tabColorizer.getDividerColor(i));
160fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            canvas.drawLine(child.getRight(), separatorTop, child.getRight(),
161fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas                    separatorTop + dividerHeightPx, mDividerPaint);
162fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
163fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
164fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
165fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    /**
166fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     * Set the alpha value of the {@code color} to be the given {@code alpha} value.
167fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     */
168fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static int setColorAlpha(int color, byte alpha) {
169fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
170fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
171fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
172fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    /**
173fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     * Blend {@code color1} and {@code color2} using the given ratio.
174fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     *
175fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
176fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     *              0.0 will return {@code color2}.
177fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas     */
178fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static int blendColors(int color1, int color2, float ratio) {
179fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        final float inverseRation = 1f - ratio;
180fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
181fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
182fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
183fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        return Color.rgb((int) r, (int) g, (int) b);
184fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
185fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
186fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    private static class SimpleTabColorizer implements SlidingTabLayout.TabColorizer {
187fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        private int[] mIndicatorColors;
188fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        private int[] mDividerColors;
189fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
190fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        @Override
191fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        public final int getIndicatorColor(int position) {
192fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            return mIndicatorColors[position % mIndicatorColors.length];
193fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
194fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
195fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        @Override
196fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        public final int getDividerColor(int position) {
197fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            return mDividerColors[position % mDividerColors.length];
198fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
199fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
200fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        void setIndicatorColors(int... colors) {
201fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            mIndicatorColors = colors;
202fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
203fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas
204fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        void setDividerColors(int... colors) {
205fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas            mDividerColors = colors;
206fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas        }
207fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas    }
208fb5e574e7953a646b95652632d0c4c87a47f4d5eAlexander Lucas}