Skip to content
This repository has been archived by the owner on Apr 19, 2018. It is now read-only.

Dev #422

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: java

branches:
except:
- gh-pages

notifications:
email: false

before_install:
- wget http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz
- tar -zxf android-sdk_r21.0.1-linux.tgz
- export ANDROID_HOME=~/builds/JakeWharton/Android-ViewPagerIndicator/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
- TOOLS=$(android list sdk --no-ui | grep "Android SDK Platform-tools" | cut -d"-" -f1)
- android update sdk --filter "$TOOLS" --no-ui --force
- SDK=$(android list sdk --no-ui | grep ", API 16," | cut -d"-" -f1)
- android update sdk --filter "$SDK" --no-ui --force
79 changes: 31 additions & 48 deletions library/pom.xml
Original file line number Diff line number Diff line change
@@ -1,57 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<artifactId>library</artifactId>
<name>Android-ViewPagerIndicator</name>
<packaging>apklib</packaging>
<artifactId>library</artifactId>
<name>ViewPagerIndicator</name>
<packaging>apklib</packaging>

<parent>
<groupId>com.viewpagerindicator</groupId>
<artifactId>parent</artifactId>
<version>2.4.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<parent>
<groupId>com.viewpagerindicator</groupId>
<artifactId>parent</artifactId>
<version>2.4.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<build>
<sourceDirectory>src</sourceDirectory>

<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>../checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
2 changes: 2 additions & 0 deletions library/res/values/vpi__attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<attr name="android:orientation"/>
<!-- Radius of the circles. This is also the spacing between circles. -->
<attr name="radius" format="dimension" />
<!-- Additional spacing between the circles. -->
<attr name="gap" format="dimension" />
<!-- Whether or not the selected indicator snaps to the circles. -->
<attr name="snap" format="boolean" />
<!-- Color of the open circles. -->
Expand Down
1 change: 1 addition & 0 deletions library/res/values/vpi__defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<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>
<dimen name="default_circle_indicator_gap">0dp</dimen>
<bool name="default_circle_indicator_snap">false</bool>
<color name="default_circle_indicator_stroke_color">#FFDDDDDD</color>
<dimen name="default_circle_indicator_stroke_width">1dp</dimen>
Expand Down
16 changes: 14 additions & 2 deletions library/src/com/viewpagerindicator/CirclePageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
private static final int INVALID_POINTER = -1;

private float mRadius;
private float mGap;
private final Paint mPaintPageFill = new Paint(ANTI_ALIAS_FLAG);
private final Paint mPaintStroke = new Paint(ANTI_ALIAS_FLAG);
private final Paint mPaintFill = new Paint(ANTI_ALIAS_FLAG);
Expand Down Expand Up @@ -84,6 +85,7 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
final float defaultGap = res.getDimension(R.dimen.default_circle_indicator_gap);
final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

Expand All @@ -100,6 +102,7 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
mPaintFill.setStyle(Style.FILL);
mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
mGap = a.getDimension(R.styleable.CirclePageIndicator_gap, defaultGap);
mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
Expand Down Expand Up @@ -185,6 +188,15 @@ public float getRadius() {
return mRadius;
}

public void setGap(float gap) {
mGap = gap;
invalidate();
}

public float getGapSize() {
return mGap;
}

public void setSnap(boolean snap) {
mSnap = snap;
invalidate();
Expand Down Expand Up @@ -227,9 +239,9 @@ protected void onDraw(Canvas canvas) {
shortPaddingBefore = getPaddingLeft();
}

final float threeRadius = mRadius * 3;
final float threeRadius = mRadius * 3 + mGap;
final float shortOffset = shortPaddingBefore + mRadius;
float longOffset = longPaddingBefore + mRadius;
float longOffset = longPaddingBefore + mRadius + mGap;
if (mCentered) {
longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f);
}
Expand Down
Loading