mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-25 02:12:16 -05:00
Update ViewPagerIndicator dependency to latest version.
This commit is contained in:
parent
35b896c3d6
commit
c292892307
@ -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>
|
||||
|
@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
</lint>
|
@ -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>
|
||||
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
@ -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>
|
||||
|
@ -41,6 +41,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
|
||||
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 class CirclePageIndicator extends View implements PageIndicator {
|
||||
|
||||
//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 class CirclePageIndicator extends View implements PageIndicator {
|
||||
|
||||
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 class CirclePageIndicator extends View implements PageIndicator {
|
||||
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 @@ public class CirclePageIndicator extends View implements PageIndicator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCurrentPage >= count) {
|
||||
setCurrentItem(count - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
int longSize;
|
||||
int longPaddingBefore;
|
||||
int longPaddingAfter;
|
||||
@ -220,6 +239,11 @@ public class CirclePageIndicator extends View implements PageIndicator {
|
||||
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,8 +254,16 @@ public class CirclePageIndicator extends View implements PageIndicator {
|
||||
dX = shortOffset;
|
||||
dY = drawLong;
|
||||
}
|
||||
// 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
|
||||
float cx = (mSnap ? mSnapPage : mCurrentPage) * threeRadius;
|
||||
@ -249,6 +281,9 @@ public class CirclePageIndicator extends View implements PageIndicator {
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(android.view.MotionEvent ev) {
|
||||
if (super.onTouchEvent(ev)) {
|
||||
return true;
|
||||
}
|
||||
if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -321,10 +321,12 @@ public class TitlePageIndicator extends View implements PageIndicator {
|
||||
|
||||
//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 @@ public class TitlePageIndicator extends View implements PageIndicator {
|
||||
}
|
||||
|
||||
//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 @@ public class TitlePageIndicator extends View implements PageIndicator {
|
||||
|
||||
//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 @@ public class TitlePageIndicator extends View implements PageIndicator {
|
||||
break;
|
||||
|
||||
case Underline:
|
||||
if (!currentSelected) {
|
||||
if (!currentSelected || page >= boundsSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -460,6 +467,9 @@ public class TitlePageIndicator extends View implements PageIndicator {
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(android.view.MotionEvent ev) {
|
||||
if (super.onTouchEvent(ev)) {
|
||||
return true;
|
||||
}
|
||||
if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user