() {
437 | @Override
438 | public SavedState createFromParcel(Parcel in) {
439 | return new SavedState(in);
440 | }
441 |
442 | @Override
443 | public SavedState[] newArray(int size) {
444 | return new SavedState[size];
445 | }
446 | };
447 | }
448 | }
--------------------------------------------------------------------------------
/library/src/com/viewpagerindicator/PageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Patrik Akerfeldt
3 | * Copyright (C) 2011 Jake Wharton
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.viewpagerindicator;
19 |
20 | import android.support.v4.view.ViewPager;
21 |
22 | /**
23 | * A PageIndicator is responsible to show an visual indicator on the total views
24 | * number and the current visible view.
25 | */
26 | public interface PageIndicator extends ViewPager.OnPageChangeListener {
27 | /**
28 | * Bind the indicator to a ViewPager.
29 | *
30 | * @param view
31 | */
32 | void setViewPager(ViewPager view);
33 |
34 | /**
35 | * Bind the indicator to a ViewPager.
36 | *
37 | * @param view
38 | * @param initialPosition
39 | */
40 | void setViewPager(ViewPager view, int initialPosition);
41 |
42 | /**
43 | * Set the current page of both the ViewPager and indicator.
44 | *
45 | * This must be used if you need to set the page before
46 | * the views are drawn on screen (e.g., default start page).
47 | *
48 | * @param item
49 | */
50 | void setCurrentItem(int item);
51 |
52 | /**
53 | * Set a page change listener which will receive forwarded events.
54 | *
55 | * @param listener
56 | */
57 | void setOnPageChangeListener(ViewPager.OnPageChangeListener listener);
58 |
59 | /**
60 | * Notify the indicator that the fragment list has changed.
61 | */
62 | void notifyDataSetChanged();
63 | }
64 |
--------------------------------------------------------------------------------
/library/src/com/viewpagerindicator/TabPageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | * Copyright (C) 2011 Jake Wharton
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.viewpagerindicator;
18 |
19 | import android.content.Context;
20 | import android.support.v4.view.PagerAdapter;
21 | import android.support.v4.view.ViewPager;
22 | import android.support.v4.view.ViewPager.OnPageChangeListener;
23 | import android.util.AttributeSet;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.HorizontalScrollView;
27 | import android.widget.LinearLayout;
28 | import android.widget.TextView;
29 |
30 | import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
31 | import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
32 |
33 | /**
34 | * This widget implements the dynamic action bar tab behavior that can change
35 | * across different configurations or circumstances.
36 | */
37 | public class TabPageIndicator extends HorizontalScrollView implements PageIndicator {
38 | /** Title text used when no title is provided by the adapter. */
39 | private static final CharSequence EMPTY_TITLE = "";
40 |
41 | /**
42 | * Interface for a callback when the selected tab has been reselected.
43 | */
44 | public interface OnTabReselectedListener {
45 | /**
46 | * Callback when the selected tab has been reselected.
47 | *
48 | * @param position Position of the current center item.
49 | */
50 | void onTabReselected(int position);
51 | }
52 |
53 | private Runnable mTabSelector;
54 |
55 | private final OnClickListener mTabClickListener = new OnClickListener() {
56 | public void onClick(View view) {
57 | TabView tabView = (TabView)view;
58 | final int oldSelected = mViewPager.getCurrentItem();
59 | final int newSelected = tabView.getIndex();
60 | mViewPager.setCurrentItem(newSelected);
61 | if (oldSelected == newSelected && mTabReselectedListener != null) {
62 | mTabReselectedListener.onTabReselected(newSelected);
63 | }
64 | }
65 | };
66 |
67 | private final IcsLinearLayout mTabLayout;
68 |
69 | private ViewPager mViewPager;
70 | private ViewPager.OnPageChangeListener mListener;
71 |
72 | private int mMaxTabWidth;
73 | private int mSelectedTabIndex;
74 |
75 | private OnTabReselectedListener mTabReselectedListener;
76 |
77 | public TabPageIndicator(Context context) {
78 | this(context, null);
79 | }
80 |
81 | public TabPageIndicator(Context context, AttributeSet attrs) {
82 | super(context, attrs);
83 | setHorizontalScrollBarEnabled(false);
84 |
85 | mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle);
86 | addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
87 | }
88 |
89 | public void setOnTabReselectedListener(OnTabReselectedListener listener) {
90 | mTabReselectedListener = listener;
91 | }
92 |
93 | @Override
94 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
95 | final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
96 | final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
97 | setFillViewport(lockedExpanded);
98 |
99 | final int childCount = mTabLayout.getChildCount();
100 | if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
101 | if (childCount > 2) {
102 | mMaxTabWidth = (int)(MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
103 | } else {
104 | mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
105 | }
106 | } else {
107 | mMaxTabWidth = -1;
108 | }
109 |
110 | final int oldWidth = getMeasuredWidth();
111 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
112 | final int newWidth = getMeasuredWidth();
113 |
114 | if (lockedExpanded && oldWidth != newWidth) {
115 | // Recenter the tab display if we're at a new (scrollable) size.
116 | setCurrentItem(mSelectedTabIndex);
117 | }
118 | }
119 |
120 | private void animateToTab(final int position) {
121 | final View tabView = mTabLayout.getChildAt(position);
122 | if (mTabSelector != null) {
123 | removeCallbacks(mTabSelector);
124 | }
125 | mTabSelector = new Runnable() {
126 | public void run() {
127 | final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
128 | smoothScrollTo(scrollPos, 0);
129 | mTabSelector = null;
130 | }
131 | };
132 | post(mTabSelector);
133 | }
134 |
135 | @Override
136 | public void onAttachedToWindow() {
137 | super.onAttachedToWindow();
138 | if (mTabSelector != null) {
139 | // Re-post the selector we saved
140 | post(mTabSelector);
141 | }
142 | }
143 |
144 | @Override
145 | public void onDetachedFromWindow() {
146 | super.onDetachedFromWindow();
147 | if (mTabSelector != null) {
148 | removeCallbacks(mTabSelector);
149 | }
150 | }
151 |
152 | private void addTab(int index, CharSequence text, int iconResId) {
153 | final TabView tabView = new TabView(getContext());
154 | tabView.mIndex = index;
155 | tabView.setFocusable(true);
156 | tabView.setOnClickListener(mTabClickListener);
157 | tabView.setText(text);
158 |
159 | if (iconResId != 0) {
160 | tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
161 | }
162 |
163 | mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
164 | }
165 |
166 | @Override
167 | public void onPageScrollStateChanged(int arg0) {
168 | if (mListener != null) {
169 | mListener.onPageScrollStateChanged(arg0);
170 | }
171 | }
172 |
173 | @Override
174 | public void onPageScrolled(int arg0, float arg1, int arg2) {
175 | if (mListener != null) {
176 | mListener.onPageScrolled(arg0, arg1, arg2);
177 | }
178 | }
179 |
180 | @Override
181 | public void onPageSelected(int arg0) {
182 | setCurrentItem(arg0);
183 | if (mListener != null) {
184 | mListener.onPageSelected(arg0);
185 | }
186 | }
187 |
188 | @Override
189 | public void setViewPager(ViewPager view) {
190 | if (mViewPager == view) {
191 | return;
192 | }
193 | if (mViewPager != null) {
194 | mViewPager.setOnPageChangeListener(null);
195 | }
196 | final PagerAdapter adapter = view.getAdapter();
197 | if (adapter == null) {
198 | throw new IllegalStateException("ViewPager does not have adapter instance.");
199 | }
200 | mViewPager = view;
201 | view.setOnPageChangeListener(this);
202 | notifyDataSetChanged();
203 | }
204 |
205 | public void notifyDataSetChanged() {
206 | mTabLayout.removeAllViews();
207 | PagerAdapter adapter = mViewPager.getAdapter();
208 | IconPagerAdapter iconAdapter = null;
209 | if (adapter instanceof IconPagerAdapter) {
210 | iconAdapter = (IconPagerAdapter)adapter;
211 | }
212 | final int count = adapter.getCount();
213 | for (int i = 0; i < count; i++) {
214 | CharSequence title = adapter.getPageTitle(i);
215 | if (title == null) {
216 | title = EMPTY_TITLE;
217 | }
218 | int iconResId = 0;
219 | if (iconAdapter != null) {
220 | iconResId = iconAdapter.getIconResId(i);
221 | }
222 | addTab(i, title, iconResId);
223 | }
224 | if (mSelectedTabIndex > count) {
225 | mSelectedTabIndex = count - 1;
226 | }
227 | setCurrentItem(mSelectedTabIndex);
228 | requestLayout();
229 | }
230 |
231 | @Override
232 | public void setViewPager(ViewPager view, int initialPosition) {
233 | setViewPager(view);
234 | setCurrentItem(initialPosition);
235 | }
236 |
237 | @Override
238 | public void setCurrentItem(int item) {
239 | if (mViewPager == null) {
240 | throw new IllegalStateException("ViewPager has not been bound.");
241 | }
242 | mSelectedTabIndex = item;
243 | mViewPager.setCurrentItem(item);
244 |
245 | final int tabCount = mTabLayout.getChildCount();
246 | for (int i = 0; i < tabCount; i++) {
247 | final View child = mTabLayout.getChildAt(i);
248 | final boolean isSelected = (i == item);
249 | child.setSelected(isSelected);
250 | if (isSelected) {
251 | animateToTab(item);
252 | }
253 | }
254 | }
255 |
256 | @Override
257 | public void setOnPageChangeListener(OnPageChangeListener listener) {
258 | mListener = listener;
259 | }
260 |
261 | private class TabView extends TextView {
262 | private int mIndex;
263 |
264 | public TabView(Context context) {
265 | super(context, null, R.attr.vpiTabPageIndicatorStyle);
266 | }
267 |
268 | @Override
269 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
270 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
271 |
272 | // Re-measure if we went beyond our maximum size.
273 | if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
274 | super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth, MeasureSpec.EXACTLY),
275 | heightMeasureSpec);
276 | }
277 | }
278 |
279 | public int getIndex() {
280 | return mIndex;
281 | }
282 | }
283 | }
284 |
--------------------------------------------------------------------------------
/library/src/com/viewpagerindicator/UnderlinePageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Jake Wharton
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.viewpagerindicator;
17 |
18 | import android.content.Context;
19 | import android.content.res.Resources;
20 | import android.content.res.TypedArray;
21 | import android.graphics.Canvas;
22 | import android.graphics.Paint;
23 | import android.graphics.drawable.Drawable;
24 | import android.os.Parcel;
25 | import android.os.Parcelable;
26 | import android.support.v4.view.MotionEventCompat;
27 | import android.support.v4.view.ViewConfigurationCompat;
28 | import android.support.v4.view.ViewPager;
29 | import android.util.AttributeSet;
30 | import android.view.MotionEvent;
31 | import android.view.View;
32 | import android.view.ViewConfiguration;
33 |
34 | /**
35 | * Draws a line for each page. The current page line is colored differently
36 | * than the unselected page lines.
37 | */
38 | public class UnderlinePageIndicator extends View implements PageIndicator {
39 | private static final int INVALID_POINTER = -1;
40 | private static final int FADE_FRAME_MS = 30;
41 |
42 | private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
43 |
44 | private boolean mFades;
45 | private int mFadeDelay;
46 | private int mFadeLength;
47 | private int mFadeBy;
48 |
49 | private ViewPager mViewPager;
50 | private ViewPager.OnPageChangeListener mListener;
51 | private int mScrollState;
52 | private int mCurrentPage;
53 | private float mPositionOffset;
54 |
55 | private int mTouchSlop;
56 | private float mLastMotionX = -1;
57 | private int mActivePointerId = INVALID_POINTER;
58 | private boolean mIsDragging;
59 |
60 | private final Runnable mFadeRunnable = new Runnable() {
61 | @Override public void run() {
62 | if (!mFades) return;
63 |
64 | final int alpha = Math.max(mPaint.getAlpha() - mFadeBy, 0);
65 | mPaint.setAlpha(alpha);
66 | invalidate();
67 | if (alpha > 0) {
68 | postDelayed(this, FADE_FRAME_MS);
69 | }
70 | }
71 | };
72 |
73 | public UnderlinePageIndicator(Context context) {
74 | this(context, null);
75 | }
76 |
77 | public UnderlinePageIndicator(Context context, AttributeSet attrs) {
78 | this(context, attrs, R.attr.vpiUnderlinePageIndicatorStyle);
79 | }
80 |
81 | public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
82 | super(context, attrs, defStyle);
83 | if (isInEditMode()) return;
84 |
85 | final Resources res = getResources();
86 |
87 | //Load defaults from resources
88 | final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
89 | final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
90 | final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
91 | final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);
92 |
93 | //Retrieve styles attributes
94 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);
95 |
96 | setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
97 | setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
98 | setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
99 | setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));
100 |
101 | Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
102 | if (background != null) {
103 | setBackgroundDrawable(background);
104 | }
105 |
106 | a.recycle();
107 |
108 | final ViewConfiguration configuration = ViewConfiguration.get(context);
109 | mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
110 | }
111 |
112 | public boolean getFades() {
113 | return mFades;
114 | }
115 |
116 | public void setFades(boolean fades) {
117 | if (fades != mFades) {
118 | mFades = fades;
119 | if (fades) {
120 | post(mFadeRunnable);
121 | } else {
122 | removeCallbacks(mFadeRunnable);
123 | mPaint.setAlpha(0xFF);
124 | invalidate();
125 | }
126 | }
127 | }
128 |
129 | public int getFadeDelay() {
130 | return mFadeDelay;
131 | }
132 |
133 | public void setFadeDelay(int fadeDelay) {
134 | mFadeDelay = fadeDelay;
135 | }
136 |
137 | public int getFadeLength() {
138 | return mFadeLength;
139 | }
140 |
141 | public void setFadeLength(int fadeLength) {
142 | mFadeLength = fadeLength;
143 | mFadeBy = 0xFF / (mFadeLength / FADE_FRAME_MS);
144 | }
145 |
146 | public int getSelectedColor() {
147 | return mPaint.getColor();
148 | }
149 |
150 | public void setSelectedColor(int selectedColor) {
151 | mPaint.setColor(selectedColor);
152 | invalidate();
153 | }
154 |
155 | @Override
156 | protected void onDraw(Canvas canvas) {
157 | super.onDraw(canvas);
158 |
159 | if (mViewPager == null) {
160 | return;
161 | }
162 | final int count = mViewPager.getAdapter().getCount();
163 | if (count == 0) {
164 | return;
165 | }
166 |
167 | if (mCurrentPage >= count) {
168 | setCurrentItem(count - 1);
169 | return;
170 | }
171 |
172 | final int paddingLeft = getPaddingLeft();
173 | final float pageWidth = (getWidth() - paddingLeft - getPaddingRight()) / (1f * count);
174 | final float left = paddingLeft + pageWidth * (mCurrentPage + mPositionOffset);
175 | final float right = left + pageWidth;
176 | final float top = getPaddingTop();
177 | final float bottom = getHeight() - getPaddingBottom();
178 | canvas.drawRect(left, top, right, bottom, mPaint);
179 | }
180 |
181 | public boolean onTouchEvent(MotionEvent ev) {
182 | if (super.onTouchEvent(ev)) {
183 | return true;
184 | }
185 | if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
186 | return false;
187 | }
188 |
189 | final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
190 | switch (action) {
191 | case MotionEvent.ACTION_DOWN:
192 | mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
193 | mLastMotionX = ev.getX();
194 | break;
195 |
196 | case MotionEvent.ACTION_MOVE: {
197 | final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
198 | final float x = MotionEventCompat.getX(ev, activePointerIndex);
199 | final float deltaX = x - mLastMotionX;
200 |
201 | if (!mIsDragging) {
202 | if (Math.abs(deltaX) > mTouchSlop) {
203 | mIsDragging = true;
204 | }
205 | }
206 |
207 | if (mIsDragging) {
208 | mLastMotionX = x;
209 | if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
210 | mViewPager.fakeDragBy(deltaX);
211 | }
212 | }
213 |
214 | break;
215 | }
216 |
217 | case MotionEvent.ACTION_CANCEL:
218 | case MotionEvent.ACTION_UP:
219 | if (!mIsDragging) {
220 | final int count = mViewPager.getAdapter().getCount();
221 | final int width = getWidth();
222 | final float halfWidth = width / 2f;
223 | final float sixthWidth = width / 6f;
224 |
225 | if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
226 | if (action != MotionEvent.ACTION_CANCEL) {
227 | mViewPager.setCurrentItem(mCurrentPage - 1);
228 | }
229 | return true;
230 | } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
231 | if (action != MotionEvent.ACTION_CANCEL) {
232 | mViewPager.setCurrentItem(mCurrentPage + 1);
233 | }
234 | return true;
235 | }
236 | }
237 |
238 | mIsDragging = false;
239 | mActivePointerId = INVALID_POINTER;
240 | if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
241 | break;
242 |
243 | case MotionEventCompat.ACTION_POINTER_DOWN: {
244 | final int index = MotionEventCompat.getActionIndex(ev);
245 | mLastMotionX = MotionEventCompat.getX(ev, index);
246 | mActivePointerId = MotionEventCompat.getPointerId(ev, index);
247 | break;
248 | }
249 |
250 | case MotionEventCompat.ACTION_POINTER_UP:
251 | final int pointerIndex = MotionEventCompat.getActionIndex(ev);
252 | final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
253 | if (pointerId == mActivePointerId) {
254 | final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
255 | mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
256 | }
257 | mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
258 | break;
259 | }
260 |
261 | return true;
262 | }
263 |
264 | @Override
265 | public void setViewPager(ViewPager viewPager) {
266 | if (mViewPager == viewPager) {
267 | return;
268 | }
269 | if (mViewPager != null) {
270 | //Clear us from the old pager.
271 | mViewPager.setOnPageChangeListener(null);
272 | }
273 | if (viewPager.getAdapter() == null) {
274 | throw new IllegalStateException("ViewPager does not have adapter instance.");
275 | }
276 | mViewPager = viewPager;
277 | mViewPager.setOnPageChangeListener(this);
278 | invalidate();
279 | post(new Runnable() {
280 | @Override public void run() {
281 | if (mFades) {
282 | post(mFadeRunnable);
283 | }
284 | }
285 | });
286 | }
287 |
288 | @Override
289 | public void setViewPager(ViewPager view, int initialPosition) {
290 | setViewPager(view);
291 | setCurrentItem(initialPosition);
292 | }
293 |
294 | @Override
295 | public void setCurrentItem(int item) {
296 | if (mViewPager == null) {
297 | throw new IllegalStateException("ViewPager has not been bound.");
298 | }
299 | mViewPager.setCurrentItem(item);
300 | mCurrentPage = item;
301 | invalidate();
302 | }
303 |
304 | @Override
305 | public void notifyDataSetChanged() {
306 | invalidate();
307 | }
308 |
309 | @Override
310 | public void onPageScrollStateChanged(int state) {
311 | mScrollState = state;
312 |
313 | if (mListener != null) {
314 | mListener.onPageScrollStateChanged(state);
315 | }
316 | }
317 |
318 | @Override
319 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
320 | mCurrentPage = position;
321 | mPositionOffset = positionOffset;
322 | if (mFades) {
323 | if (positionOffsetPixels > 0) {
324 | removeCallbacks(mFadeRunnable);
325 | mPaint.setAlpha(0xFF);
326 | } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) {
327 | postDelayed(mFadeRunnable, mFadeDelay);
328 | }
329 | }
330 | invalidate();
331 |
332 | if (mListener != null) {
333 | mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
334 | }
335 | }
336 |
337 | @Override
338 | public void onPageSelected(int position) {
339 | if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
340 | mCurrentPage = position;
341 | mPositionOffset = 0;
342 | invalidate();
343 | mFadeRunnable.run();
344 | }
345 | if (mListener != null) {
346 | mListener.onPageSelected(position);
347 | }
348 | }
349 |
350 | @Override
351 | public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
352 | mListener = listener;
353 | }
354 |
355 | @Override
356 | public void onRestoreInstanceState(Parcelable state) {
357 | SavedState savedState = (SavedState)state;
358 | super.onRestoreInstanceState(savedState.getSuperState());
359 | mCurrentPage = savedState.currentPage;
360 | requestLayout();
361 | }
362 |
363 | @Override
364 | public Parcelable onSaveInstanceState() {
365 | Parcelable superState = super.onSaveInstanceState();
366 | SavedState savedState = new SavedState(superState);
367 | savedState.currentPage = mCurrentPage;
368 | return savedState;
369 | }
370 |
371 | static class SavedState extends BaseSavedState {
372 | int currentPage;
373 |
374 | public SavedState(Parcelable superState) {
375 | super(superState);
376 | }
377 |
378 | private SavedState(Parcel in) {
379 | super(in);
380 | currentPage = in.readInt();
381 | }
382 |
383 | @Override
384 | public void writeToParcel(Parcel dest, int flags) {
385 | super.writeToParcel(dest, flags);
386 | dest.writeInt(currentPage);
387 | }
388 |
389 | @SuppressWarnings("UnusedDeclaration")
390 | public static final Creator CREATOR = new Creator() {
391 | @Override
392 | public SavedState createFromParcel(Parcel in) {
393 | return new SavedState(in);
394 | }
395 |
396 | @Override
397 | public SavedState[] newArray(int size) {
398 | return new SavedState[size];
399 | }
400 | };
401 | }
402 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 |
7 | org.sonatype.oss
8 | oss-parent
9 | 7
10 |
11 |
12 | com.viewpagerindicator
13 | parent
14 | pom
15 | 2.4.1
16 |
17 | Android-ViewPagerIndicator (Parent)
18 | Android library for.
19 | https://github.com/JakeWharton/Android-ViewPagerIndicator
20 | 2011
21 |
22 |
23 | library
24 | sample
25 |
26 |
27 |
28 | http://github.com/JakeWharton/Android-ViewPagerIndicator/
29 | scm:git:git://github.com/JakeWharton/Android-ViewPagerIndicator.git
30 | scm:git:git@github.com:JakeWharton/Android-ViewPagerIndicator.git
31 |
32 |
33 |
34 |
35 | Jake Wharton
36 | jakewharton@gmail.com
37 | jakewharton
38 | http://jakewharton.com
39 | -5
40 |
41 | developer
42 |
43 |
44 |
45 |
46 |
47 |
48 | Apache License Version 2.0
49 | http://www.apache.org/licenses/LICENSE-2.0.txt
50 | repo
51 |
52 |
53 |
54 |
55 | Jake Wharton
56 | http://jakewharton.com
57 |
58 |
59 |
60 | GitHub Issues
61 | https://github.com/JakeWharton/Android-ViewPagerIndicator/issues
62 |
63 |
64 |
65 | UTF-8
66 | UTF-8
67 |
68 | 1.6
69 | 4.1.1.4
70 | 16
71 | r7
72 |
73 | 3.3.0
74 |
75 |
76 |
77 |
78 |
79 | com.google.android
80 | android
81 | ${android.version}
82 |
83 |
84 |
85 | com.google.android
86 | support-v4
87 | ${android.support.version}
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | org.apache.maven.plugins
97 | maven-compiler-plugin
98 | 2.3.2
99 |
100 | ${java.version}
101 | ${java.version}
102 |
103 |
104 |
105 |
106 | com.jayway.maven.plugins.android.generation2
107 | android-maven-plugin
108 | ${android-maven.version}
109 |
110 |
111 | ${android.platform}
112 |
113 | true
114 |
115 | true
116 |
117 |
118 |
119 | org.apache.maven.plugins
120 | maven-checkstyle-plugin
121 | 2.6
122 |
123 | true
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | org.apache.maven.plugins
132 | maven-release-plugin
133 | 2.1
134 |
135 | true
136 |
137 |
138 |
139 |
140 | org.apache.maven.plugins
141 | maven-eclipse-plugin
142 | 2.9
143 |
144 |
145 | android:android
146 | com.google.android.maps:maps
147 |
148 | bin
149 |
150 | com.android.ide.eclipse.adt.ANDROID_FRAMEWORK
151 |
152 |
153 | com.android.ide.eclipse.adt.AndroidNature
154 | org.eclipse.ajdt.ui.ajnature
155 |
156 |
157 | com.android.ide.eclipse.adt.ResourceManagerBuilder
158 | com.android.ide.eclipse.adt.PreCompilerBuilder
159 | org.eclipse.jdt.core.javabuilder
160 | com.android.ide.eclipse.adt.ApkBuilder
161 |
162 | false
163 |
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/sample/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
47 |
48 |
49 |
50 |
51 |
52 |
56 |
57 |
58 |
59 |
60 |
61 |
65 |
66 |
67 |
68 |
69 |
70 |
74 |
75 |
76 |
77 |
78 |
79 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
107 |
108 |
109 |
110 |
111 |
112 |
116 |
117 |
118 |
119 |
120 |
121 |
125 |
126 |
127 |
128 |
129 |
130 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
146 |
147 |
148 |
149 |
150 |
151 |
154 |
155 |
156 |
157 |
158 |
159 |
162 |
163 |
164 |
165 |
166 |
167 |
170 |
171 |
172 |
173 |
174 |
175 |
179 |
180 |
181 |
182 |
183 |
184 |
188 |
189 |
190 |
191 |
192 |
193 |
197 |
198 |
199 |
200 |
201 |
202 |
205 |
206 |
207 |
208 |
209 |
210 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
226 |
227 |
228 |
229 |
230 |
231 |
235 |
236 |
237 |
238 |
239 |
240 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
256 |
257 |
258 |
259 |
260 |
261 |
264 |
265 |
266 |
267 |
268 |
269 |
273 |
274 |
275 |
276 |
277 |
278 |
282 |
283 |
284 |
285 |
286 |
287 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
--------------------------------------------------------------------------------
/sample/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/sample/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/logo.png
--------------------------------------------------------------------------------
/sample/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 | sample
7 | Android-ViewPagerIndicator Sample
8 | apk
9 |
10 |
11 | com.viewpagerindicator
12 | parent
13 | 2.4.1
14 | ../pom.xml
15 |
16 |
17 |
18 |
19 | com.google.android
20 | android
21 | provided
22 |
23 |
24 |
25 | com.google.android
26 | support-v4
27 |
28 |
29 |
30 | com.viewpagerindicator
31 | library
32 | ${project.version}
33 | apklib
34 |
35 |
36 |
37 |
38 | src
39 | ${project.artifactId}-unaligned
40 |
41 |
42 |
43 | com.jayway.maven.plugins.android.generation2
44 | android-maven-plugin
45 | true
46 |
47 |
48 |
49 | org.apache.maven.plugins
50 | maven-checkstyle-plugin
51 |
52 | ../checkstyle.xml
53 |
54 |
55 |
56 | verify
57 |
58 | checkstyle
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | release
69 |
70 |
71 | performRelease
72 | true
73 |
74 |
75 |
76 |
77 |
78 | com.jayway.maven.plugins.android.generation2
79 | android-maven-plugin
80 | ${android-maven.version}
81 | true
82 |
83 |
84 | ${project.build.directory}/${project.build.finalName}.apk
85 | ${project.build.directory}/${project.artifactId}.apk
86 |
87 |
88 |
89 |
90 | alignApk
91 | package
92 |
93 | zipalign
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/sample/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-16
12 | android.library.reference.1=../library
13 |
--------------------------------------------------------------------------------
/sample/psd/icon_hdpi.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/psd/icon_hdpi.psd
--------------------------------------------------------------------------------
/sample/psd/icon_mdpi.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/psd/icon_mdpi.psd
--------------------------------------------------------------------------------
/sample/psd/icon_xhdpi.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/psd/icon_xhdpi.psd
--------------------------------------------------------------------------------
/sample/psd/logo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/psd/logo.psd
--------------------------------------------------------------------------------
/sample/psd/web.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/psd/web.psd
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_divider.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_divider.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_selected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_selected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_selected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_selected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_unselected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_unselected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_unselected_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_unselected_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/custom_tab_indicator_unselected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/custom_tab_indicator_unselected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_calendar_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_calendar_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_calendar_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_calendar_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_camera_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_camera_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_camera_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_camera_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_device_alarms_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_device_alarms_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_device_alarms_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_device_alarms_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_location_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_location_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-hdpi/perm_group_location_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-hdpi/perm_group_location_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_divider.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_divider.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_selected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_selected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_selected_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_selected_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_selected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_selected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_unselected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_unselected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_unselected_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_unselected_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/custom_tab_indicator_unselected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/custom_tab_indicator_unselected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_calendar_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_calendar_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_calendar_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_calendar_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_camera_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_camera_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_camera_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_camera_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_device_alarms_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_device_alarms_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_device_alarms_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_device_alarms_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_location_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_location_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-mdpi/perm_group_location_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-mdpi/perm_group_location_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_divider.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_divider.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_selected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_selected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_selected_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_selected_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_selected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_selected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_unselected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_unselected.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_unselected_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_unselected_focused.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/custom_tab_indicator_unselected_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/custom_tab_indicator_unselected_pressed.9.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_calendar_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_calendar_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_calendar_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_calendar_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_camera_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_camera_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_camera_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_camera_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_device_alarms_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_device_alarms_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_device_alarms_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_device_alarms_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_location_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_location_normal.png
--------------------------------------------------------------------------------
/sample/res/drawable-xhdpi/perm_group_location_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/res/drawable-xhdpi/perm_group_location_selected.png
--------------------------------------------------------------------------------
/sample/res/drawable/custom_tab_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/res/drawable/perm_group_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/res/drawable/perm_group_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/res/drawable/perm_group_device_alarms.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/res/drawable/perm_group_location.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_circles.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
35 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_circles_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
35 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_icons.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_lines.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
35 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_titles.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
35 |
36 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_titles_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
23 |
24 |
30 |
37 |
38 |
--------------------------------------------------------------------------------
/sample/res/layout/simple_underlines.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
22 |
23 |
29 |
34 |
--------------------------------------------------------------------------------
/sample/res/layout/themed_circles.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
23 |
24 |
30 |
42 |
43 |
--------------------------------------------------------------------------------
/sample/res/layout/themed_lines.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
23 |
24 |
30 |
40 |
41 |
--------------------------------------------------------------------------------
/sample/res/layout/themed_titles.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
23 |
24 |
38 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/sample/res/layout/themed_underlines.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
23 |
24 |
30 |
39 |
40 |
--------------------------------------------------------------------------------
/sample/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/sample/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
25 |
26 |
36 |
37 |
43 |
44 |
51 |
52 |
65 |
66 |
69 |
70 |
76 |
77 |
--------------------------------------------------------------------------------
/sample/screens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JakeWharton/ViewPagerIndicator/8cd549f23f3d20ff920e19a2345c54983f65e26b/sample/screens.png
--------------------------------------------------------------------------------
/sample/src/com/viewpagerindicator/sample/BaseSampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.viewpagerindicator.sample;
2 |
3 | import java.util.Random;
4 |
5 | import com.viewpagerindicator.PageIndicator;
6 |
7 | import android.support.v4.app.FragmentActivity;
8 | import android.support.v4.view.ViewPager;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.widget.Toast;
12 |
13 | public abstract class BaseSampleActivity extends FragmentActivity {
14 | private static final Random RANDOM = new Random();
15 |
16 | TestFragmentAdapter mAdapter;
17 | ViewPager mPager;
18 | PageIndicator mIndicator;
19 |
20 | @Override
21 | public boolean onCreateOptionsMenu(Menu menu) {
22 | getMenuInflater().inflate(R.menu.menu, menu);
23 | return true;
24 | }
25 |
26 | @Override
27 | public boolean onOptionsItemSelected(MenuItem item) {
28 | switch (item.getItemId()) {
29 | case R.id.random:
30 | final int page = RANDOM.nextInt(mAdapter.getCount());
31 | Toast.makeText(this, "Changing to page " + page, Toast.LENGTH_SHORT);
32 | mPager.setCurrentItem(page);
33 | return true;
34 |
35 | case R.id.add_page:
36 | if (mAdapter.getCount() < 10) {
37 | mAdapter.setCount(mAdapter.getCount() + 1);
38 | mIndicator.notifyDataSetChanged();
39 | }
40 | return true;
41 |
42 | case R.id.remove_page:
43 | if (mAdapter.getCount() > 1) {
44 | mAdapter.setCount(mAdapter.getCount() - 1);
45 | mIndicator.notifyDataSetChanged();
46 | }
47 | return true;
48 | }
49 | return super.onOptionsItemSelected(item);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sample/src/com/viewpagerindicator/sample/ListSamples.java:
--------------------------------------------------------------------------------
1 | package com.viewpagerindicator.sample;
2 |
3 | import java.text.Collator;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 | import java.util.Comparator;
7 | import java.util.HashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 | import android.app.ListActivity;
11 | import android.content.Intent;
12 | import android.content.pm.PackageManager;
13 | import android.content.pm.ResolveInfo;
14 | import android.os.Bundle;
15 | import android.view.View;
16 | import android.widget.ListView;
17 | import android.widget.SimpleAdapter;
18 |
19 | public class ListSamples extends ListActivity {
20 |
21 | @Override
22 | public void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 |
25 | Intent intent = getIntent();
26 | String path = intent.getStringExtra("com.jakewharton.android.viewpagerindicator.sample.Path");
27 |
28 | if (path == null) {
29 | path = "";
30 | }
31 |
32 | setListAdapter(new SimpleAdapter(this, getData(path),
33 | android.R.layout.simple_list_item_1, new String[] { "title" },
34 | new int[] { android.R.id.text1 }));
35 | getListView().setTextFilterEnabled(true);
36 | }
37 |
38 | protected List