Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update ViewPagerIndicator dependency to latest version.

  • Loading branch information...
commit c292892307a3190588523797d13dfc9c4c5a42c4 1 parent 35b896c
Sebastian Kaspari authored
4 libs/ViewPagerIndicator/AndroidManifest.xml
View
@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.viewpagerindicator"
- android:versionCode="26"
- android:versionName="2.2.2">
+ android:versionCode="30"
+ android:versionName="2.2.3">
<uses-sdk android:minSdkVersion="4" />
</manifest>
3  libs/ViewPagerIndicator/lint.xml
View
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<lint>
-</lint>
6 libs/ViewPagerIndicator/pom.xml
View
@@ -11,13 +11,13 @@
<parent>
<groupId>com.viewpagerindicator</groupId>
<artifactId>parent</artifactId>
- <version>2.2.2</version>
+ <version>2.2.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
- <groupId>android</groupId>
+ <groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
@@ -35,7 +35,7 @@
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>maven-android-plugin</artifactId>
+ <artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
2  libs/ViewPagerIndicator/res/values/vpi__attrs.xml
View
@@ -34,6 +34,8 @@
<attr name="centered" format="boolean" />
<!-- Color of the filled circle that represents the current page. -->
<attr name="fillColor" format="color" />
+ <!-- Color of the filled circles that represents pages. -->
+ <attr name="pageColor" format="color" />
<!-- Orientation of the indicator. -->
<attr name="orientation">
<enum name="horizontal" value="0" />
3  libs/ViewPagerIndicator/res/values/vpi__defaults.xml
View
@@ -17,6 +17,7 @@
<resources>
<bool name="default_circle_indicator_centered">true</bool>
<color name="default_circle_indicator_fill_color">#FFFFFFFF</color>
+ <color name="default_circle_indicator_page_color">#00000000</color>
<integer name="default_circle_indicator_orientation">0</integer>
<dimen name="default_circle_indicator_radius">3dp</dimen>
<bool name="default_circle_indicator_snap">false</bool>
@@ -33,7 +34,7 @@
<color name="default_title_indicator_selected_color">#FFFFFFFF</color>
<bool name="default_title_indicator_selected_bold">true</bool>
<color name="default_title_indicator_text_color">#BBFFFFFF</color>
- <dimen name="default_title_indicator_text_size">15sp</dimen>
+ <dimen name="default_title_indicator_text_size">15dp</dimen>
<dimen name="default_title_indicator_title_padding">5dp</dimen>
<dimen name="default_title_indicator_top_padding">7dp</dimen>
</resources>
1  libs/ViewPagerIndicator/res/values/vpi__styles.xml
View
@@ -27,6 +27,7 @@
<style name="Widget.CirclePageIndicator" parent="Widget">
<item name="centered">@bool/default_circle_indicator_centered</item>
<item name="fillColor">@color/default_circle_indicator_fill_color</item>
+ <item name="pageColor">@color/default_circle_indicator_page_color</item>
<item name="orientation">@integer/default_circle_indicator_orientation</item>
<item name="radius">@dimen/default_circle_indicator_radius</item>
<item name="snap">@bool/default_circle_indicator_snap</item>
37 libs/ViewPagerIndicator/src/com/viewpagerindicator/CirclePageIndicator.java
View
@@ -41,6 +41,7 @@
public static final int VERTICAL = 1;
private float mRadius;
+ private final Paint mPaintPageFill;
private final Paint mPaintStroke;
private final Paint mPaintFill;
private ViewPager mViewPager;
@@ -75,6 +76,7 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
//Load defaults from resources
final Resources res = getResources();
+ final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
@@ -88,6 +90,9 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation);
+ mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mPaintPageFill.setStyle(Style.FILL);
+ mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintStroke.setStyle(Style.STROKE);
mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
@@ -114,6 +119,15 @@ public boolean isCentered() {
return mCentered;
}
+ public void setPageColor(int pageColor) {
+ mPaintPageFill.setColor(pageColor);
+ invalidate();
+ }
+
+ public int getPageColor() {
+ return mPaintPageFill.getColor();
+ }
+
public void setFillColor(int fillColor) {
mPaintFill.setColor(fillColor);
invalidate();
@@ -194,6 +208,11 @@ protected void onDraw(Canvas canvas) {
return;
}
+ if (mCurrentPage >= count) {
+ setCurrentItem(count - 1);
+ return;
+ }
+
int longSize;
int longPaddingBefore;
int longPaddingAfter;
@@ -220,6 +239,11 @@ protected void onDraw(Canvas canvas) {
float dX;
float dY;
+ float pageFillRadius = mRadius;
+ if (mPaintStroke.getStrokeWidth() > 0) {
+ pageFillRadius -= mPaintStroke.getStrokeWidth() / 2.0f;
+ }
+
//Draw stroked circles
for (int iLoop = 0; iLoop < count; iLoop++) {
float drawLong = longOffset + (iLoop * threeRadius);
@@ -230,7 +254,15 @@ protected void onDraw(Canvas canvas) {
dX = shortOffset;
dY = drawLong;
}
- canvas.drawCircle(dX, dY, mRadius, mPaintStroke);
+ // Only paint fill if not completely transparent
+ if (mPaintPageFill.getAlpha() > 0) {
+ canvas.drawCircle(dX, dY, pageFillRadius, mPaintPageFill);
+ }
+
+ // Only paint stroke if a stroke width was non-zero
+ if (pageFillRadius != mRadius) {
+ canvas.drawCircle(dX, dY, mRadius, mPaintStroke);
+ }
}
//Draw the filled circle according to the current scroll
@@ -249,6 +281,9 @@ protected void onDraw(Canvas canvas) {
}
public boolean onTouchEvent(android.view.MotionEvent ev) {
+ if (super.onTouchEvent(ev)) {
+ return true;
+ }
if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
return false;
}
16 libs/ViewPagerIndicator/src/com/viewpagerindicator/TitlePageIndicator.java
View
@@ -321,10 +321,12 @@ protected void onDraw(Canvas canvas) {
//Calculate views bounds
ArrayList<RectF> bounds = calculateAllBounds(mPaintText);
+ final int boundsSize = bounds.size();
//Make sure we're on a page that still exists
- if (mCurrentPage >= bounds.size()) {
- setCurrentItem(bounds.size()-1);
+ if (mCurrentPage >= boundsSize) {
+ setCurrentItem(boundsSize - 1);
+ return;
}
final int countMinusOne = count - 1;
@@ -400,6 +402,7 @@ protected void onDraw(Canvas canvas) {
}
//Now draw views
+ int colorTextAlpha = mColorText >>> 24;
for (int i = 0; i < count; i++) {
//Get the title
RectF bound = bounds.get(i);
@@ -411,6 +414,10 @@ protected void onDraw(Canvas canvas) {
//Draw text as unselected
mPaintText.setColor(mColorText);
+ if(currentPage && currentSelected) {
+ //Fade out/in unselected text as the selected text fades in/out
+ mPaintText.setAlpha(colorTextAlpha - (int)(colorTextAlpha * selectedPercent));
+ }
canvas.drawText(mTitleProvider.getTitle(i), bound.left, bound.bottom + mTopPadding, mPaintText);
//If we are within the selected bounds draw the selected text
@@ -440,7 +447,7 @@ protected void onDraw(Canvas canvas) {
break;
case Underline:
- if (!currentSelected) {
+ if (!currentSelected || page >= boundsSize) {
break;
}
@@ -460,6 +467,9 @@ protected void onDraw(Canvas canvas) {
}
public boolean onTouchEvent(android.view.MotionEvent ev) {
+ if (super.onTouchEvent(ev)) {
+ return true;
+ }
if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
return false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.