diff --git a/.gitignore b/.gitignore
index a843c2e23..18f33a429 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,14 @@ pom.xml.*
local.properties
build.xml
proguard-project.txt
+
+# Mac OS files
+.DS_Store
+
+#Gradle files
+.gradle/
+.gradle
+.gradle/*
+
+#Build
+build/
\ No newline at end of file
diff --git a/README.md b/README.md
index 88127624a..4037f429c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
Android ViewPagerIndicator
==========================
+[  ][12]
+
Paging indicator widgets that are compatible with the `ViewPager` from the
[Android Support Library][2] to improve discoverability of content.
@@ -62,22 +64,28 @@ methods.
Including In Your Project
-------------------------
-Android-ViewPagerIndicator is presented as an [Android library project][7]. A
+The new version of Android-ViewPagerIndicator in [my branch][11] is presented as an [Android library project][7]. A
standalone JAR is not possible due to the theming capabilities offered by the
indicator widgets.
-You can include this project by [referencing it as a library project][8] in
-Eclipse or ant.
+You can include this project by [referencing it as a aar file][7] in gradle.
-If you are a Maven user you can easily include the library by specifying it as
+If you are a Gradle user you can easily include the library by specifying it as
a dependency:
-
- com.viewpagerindicator
- library
- 2.4.1
- apklib
-
+ compile 'com.githang:viewpagerindicator:2.5.1'
+
+
+For SNAPSHOT version, you need to declare oss-snapshot-local repository at first:
+
+ maven { url "http://oss.jfrog.org/oss-snapshot-local/" }
+
+Then include it into your build.gradle:
+
+ compile 'com.githang:viewpagerindicator:2.5-SNAPSHOT@aar'
+
+Note: Use snapshot repository may slow down the speed of gradle resolving dependencies if you use android support library.
+
This project depends on the `ViewPager` class which is available in the
[Android Support Library][2] or [ActionBarSherlock][3]. Details for
@@ -134,7 +142,8 @@ License
[4]: https://github.com/pakerfeldt/android-viewflow
[5]: https://github.com/franciscojunior
[6]: https://gist.github.com/1122947
- [7]: http://developer.android.com/guide/developing/projects/projects-eclipse.html
- [8]: http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject
+ [7]: http://tools.android.com/tech-docs/new-build-system/aar-format
[9]: https://raw.github.com/JakeWharton/Android-ViewPagerIndicator/master/sample/screens.png
[10]: https://play.google.com/store/apps/details?id=com.viewpagerindicator.sample
+ [11]: https://github.com/msdx/ViewPagerIndicator/tree/msdx
+ [12]: https://bintray.com/msdx/maven/ViewPagerIndicator/_latestVersion
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 000000000..5321a18f6
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,16 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.0'
+ }
+}
+
+allprojects {
+ repositories {
+ mavenCentral()
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..8c0fb64a8
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..079c40da1
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Jan 05 16:46:28 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 000000000..91a7e269e
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 000000000..8a0b282aa
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/library/AndroidManifest.xml b/library/AndroidManifest.xml
deleted file mode 100644
index 4314f1b3d..000000000
--- a/library/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
diff --git a/library/bintray.gradle b/library/bintray.gradle
new file mode 100644
index 000000000..1156b0dae
--- /dev/null
+++ b/library/bintray.gradle
@@ -0,0 +1,121 @@
+group = PROJ_GROUP
+version = PROJ_VERSION
+project.archivesBaseName = PROJ_ARTIFACTID
+
+apply plugin: 'com.jfrog.bintray'
+apply plugin: 'com.github.dcendents.android-maven'
+
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+task javadoc(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += configurations.compile
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+}
+
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+
+javadoc {
+ options{
+ encoding "UTF-8"
+ charSet 'UTF-8'
+ author true
+ version true
+ links "http://docs.oracle.com/javase/7/docs/api"
+ title "$PROJ_NAME $PROJ_VERSION"
+ }
+}
+
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+}
+
+install {
+ repositories.mavenInstaller {
+ pom.project {
+ name PROJ_NAME
+ description PROJ_DESCRIPTION
+ url PROJ_WEBSITEURL
+ inceptionYear '2017'
+
+ packaging 'aar'
+ groupId PROJ_GROUP
+ artifactId PROJ_ARTIFACTID
+ version PROJ_VERSION
+
+ licenses {
+ license {
+ name 'The Apache Software License, Version 2.0'
+ url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution 'repo'
+ }
+ }
+ scm {
+ connection PROJ_VCSURL
+ url PROJ_WEBSITEURL
+
+ }
+ }
+ }
+}
+
+bintray {
+ user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : project.property('BINTRAY_USER')
+ key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : project.property('BINTRAY_KEY')
+
+ configurations = ['archives']
+
+ dryRun = false
+ publish = true
+
+ pkg {
+ repo = 'maven'
+ name = PROJ_NAME
+ licenses = ['Apache-2.0']
+ vcsUrl = PROJ_VCSURL
+ websiteUrl = PROJ_WEBSITEURL
+ issueTrackerUrl = PROJ_ISSUETRACKERURL
+ publicDownloadNumbers = true
+ version {
+ name = PROJ_VERSION
+ desc = PROJ_DESCRIPTION
+ vcsTag = PROJ_VERSION
+
+ gpg {
+ sign = true
+ }
+ }
+ }
+}
+
+//以下内容用于发布SNAPSHOT版本,如果不需要可以移除。
+//参考自:https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin
+
+apply plugin: "com.jfrog.artifactory"
+artifactory {
+ contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver
+ resolve {
+ repository {
+ repoKey = 'libs-release'
+ }
+ }
+ publish {
+ repository {
+ repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
+ username = bintray.user
+ password = bintray.key
+ maven = true
+ }
+ defaults {
+ //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去
+ publishConfigs('archives')
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 000000000..c214fec55
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,39 @@
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
+ classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0'
+ }
+}
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 22
+ buildToolsVersion '25.0.0'
+
+ defaultConfig {
+ minSdkVersion 4
+ targetSdkVersion 22
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+
+ compile 'com.android.support:support-v4:22.+'
+}
+
+if ((hasProperty('bintrayUser') || hasProperty('BINTRAY_USER')) && (hasProperty('bintrayKey') || hasProperty('BINTRAY_KEY'))) {
+ apply from: 'bintray.gradle'
+}
diff --git a/library/gradle.properties b/library/gradle.properties
new file mode 100644
index 000000000..c932f36e2
--- /dev/null
+++ b/library/gradle.properties
@@ -0,0 +1,8 @@
+PROJ_GROUP=com.githang
+PROJ_VERSION=2.5.1
+PROJ_NAME=ViewPagerIndicator
+PROJ_WEBSITEURL=https://github.com/msdx/ViewPagerIndicator/tree/msdx
+PROJ_ISSUETRACKERURL=https://github.com/JakeWharton/ViewPagerIndicator/issues
+PROJ_VCSURL=https://github.com/msdx/ViewPagerIndicator/tree/msdx
+PROJ_DESCRIPTION=Paging indicator widgets compatible with the ViewPager
+PROJ_ARTIFACTID=viewpagerindicator
diff --git a/library/libs/android-support-v4.jar b/library/libs/android-support-v4.jar
deleted file mode 100644
index 99e063b33..000000000
Binary files a/library/libs/android-support-v4.jar and /dev/null differ
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 000000000..ab2b42bac
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/gimbert/dev/android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/library/src/androidTest/java/com/viewpagerindicator/ApplicationTest.java b/library/src/androidTest/java/com/viewpagerindicator/ApplicationTest.java
new file mode 100644
index 000000000..76a0b4885
--- /dev/null
+++ b/library/src/androidTest/java/com/viewpagerindicator/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.viewpagerindicator;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..f6f442d0a
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
diff --git a/library/src/com/viewpagerindicator/CirclePageIndicator.java b/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java
similarity index 96%
rename from library/src/com/viewpagerindicator/CirclePageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java
index 885daaa6a..c95c1aa18 100644
--- a/library/src/com/viewpagerindicator/CirclePageIndicator.java
+++ b/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java
@@ -240,10 +240,10 @@ protected void onDraw(Canvas canvas) {
}
final float threeRadius = mRadius * 3 + mGap;
- final float shortOffset = shortPaddingBefore + mRadius;
- float longOffset = longPaddingBefore + mRadius + mGap;
+ final float shortOffset = shortPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2;
+ float longOffset = longPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2;
if (mCentered) {
- longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f);
+ longOffset += ((longSize - longPaddingBefore - longPaddingAfter) - (count * threeRadius - mRadius - mGap)) / 2.0f;
}
float dX;
@@ -290,7 +290,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawCircle(dX, dY, mRadius, mPaintFill);
}
- public boolean onTouchEvent(android.view.MotionEvent ev) {
+ public boolean onTouchEvent(MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
}
@@ -481,7 +481,8 @@ private int measureLong(int measureSpec) {
//Calculate the width according the views count
final int count = mViewPager.getAdapter().getCount();
result = (int)(getPaddingLeft() + getPaddingRight()
- + (count * 2 * mRadius) + (count - 1) * mRadius + 1);
+ + (count * (2 * mRadius + 1)) + (count - 1) * (mRadius + mGap)
+ + mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
@@ -507,7 +508,8 @@ private int measureShort(int measureSpec) {
result = specSize;
} else {
//Measure the height
- result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
+ result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1
+ + mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
@@ -552,7 +554,7 @@ public void writeToParcel(Parcel dest, int flags) {
}
@SuppressWarnings("UnusedDeclaration")
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
+ public static final Creator CREATOR = new Creator() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
diff --git a/library/src/com/viewpagerindicator/IconPageIndicator.java b/library/src/main/java/com/viewpagerindicator/IconPageIndicator.java
similarity index 100%
rename from library/src/com/viewpagerindicator/IconPageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/IconPageIndicator.java
diff --git a/library/src/com/viewpagerindicator/IconPagerAdapter.java b/library/src/main/java/com/viewpagerindicator/IconPagerAdapter.java
similarity index 100%
rename from library/src/com/viewpagerindicator/IconPagerAdapter.java
rename to library/src/main/java/com/viewpagerindicator/IconPagerAdapter.java
diff --git a/library/src/com/viewpagerindicator/IcsLinearLayout.java b/library/src/main/java/com/viewpagerindicator/IcsLinearLayout.java
similarity index 95%
rename from library/src/com/viewpagerindicator/IcsLinearLayout.java
rename to library/src/main/java/com/viewpagerindicator/IcsLinearLayout.java
index cbf619e42..b885c4f00 100644
--- a/library/src/com/viewpagerindicator/IcsLinearLayout.java
+++ b/library/src/main/java/com/viewpagerindicator/IcsLinearLayout.java
@@ -104,7 +104,7 @@ private void drawDividersVertical(Canvas canvas) {
if (child != null && child.getVisibility() != GONE) {
if (hasDividerBeforeChildAt(i)) {
- final android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) child.getLayoutParams();
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/;
drawHorizontalDivider(canvas, top);
}
@@ -131,7 +131,7 @@ private void drawDividersHorizontal(Canvas canvas) {
if (child != null && child.getVisibility() != GONE) {
if (hasDividerBeforeChildAt(i)) {
- final android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) child.getLayoutParams();
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
drawVerticalDivider(canvas, left);
}
diff --git a/library/src/com/viewpagerindicator/LinePageIndicator.java b/library/src/main/java/com/viewpagerindicator/LinePageIndicator.java
similarity index 98%
rename from library/src/com/viewpagerindicator/LinePageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/LinePageIndicator.java
index a009cbfbb..ef9c15dc2 100644
--- a/library/src/com/viewpagerindicator/LinePageIndicator.java
+++ b/library/src/main/java/com/viewpagerindicator/LinePageIndicator.java
@@ -27,7 +27,6 @@
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
-import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -190,7 +189,7 @@ protected void onDraw(Canvas canvas) {
}
}
- public boolean onTouchEvent(android.view.MotionEvent ev) {
+ public boolean onTouchEvent(MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
}
@@ -369,7 +368,7 @@ private int measureWidth(int measureSpec) {
result = Math.min(result, specSize);
}
}
- return (int)FloatMath.ceil(result);
+ return (int)Math.ceil(result);
}
/**
@@ -395,7 +394,7 @@ private int measureHeight(int measureSpec) {
result = Math.min(result, specSize);
}
}
- return (int)FloatMath.ceil(result);
+ return (int)Math.ceil(result);
}
@Override
@@ -433,7 +432,7 @@ public void writeToParcel(Parcel dest, int flags) {
}
@SuppressWarnings("UnusedDeclaration")
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
+ public static final Creator CREATOR = new Creator() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
diff --git a/library/src/com/viewpagerindicator/PageIndicator.java b/library/src/main/java/com/viewpagerindicator/PageIndicator.java
similarity index 100%
rename from library/src/com/viewpagerindicator/PageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/PageIndicator.java
diff --git a/library/src/main/java/com/viewpagerindicator/StripPageIndicator.java b/library/src/main/java/com/viewpagerindicator/StripPageIndicator.java
new file mode 100644
index 000000000..18ea3dd6f
--- /dev/null
+++ b/library/src/main/java/com/viewpagerindicator/StripPageIndicator.java
@@ -0,0 +1,549 @@
+/*
+* Copyright (C) 2013 Andreas Stuetz
+* Copyright (C) 2015 Huang Haohang
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.viewpagerindicator;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Paint.Style;
+import android.graphics.Typeface;
+import android.os.Build;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v4.view.ViewPager.OnPageChangeListener;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import java.util.Locale;
+
+public class StripPageIndicator extends HorizontalScrollView implements PageIndicator {
+ // @formatter:off
+ private static final int[] ATTRS = new int[]{
+ android.R.attr.textSize,
+ android.R.attr.textColor
+ };
+ // @formatter:on
+ private LinearLayout.LayoutParams mDefaultTabLayoutParams;
+ private LinearLayout.LayoutParams mExpandedTabLayoutParams;
+ public OnPageChangeListener mListener;
+ private LinearLayout mTabsContainer;
+ private ViewPager mViewPager;
+ private int mTabCount;
+ private int mCurrentPage;
+ private int mLinePosition;
+ private float mCurrentPositionOffset;
+ private Paint mRectPaint;
+ private Paint mDividerPaint;
+ private int mIndicatorColor;
+ private int mUnderlineColor;
+ private int mDividerColor;
+ private boolean mShouldExpand;
+ private boolean mTextAllCaps;
+ private int mScrollOffset;
+ private int mIndicatorHeight;
+ private int mUnderlineHeight;
+ private int mDividerPadding;
+ private int mTabPadding;
+ private int mDividerWidth;
+ private int mTabTextSize;
+ private ColorStateList mTabTextColor;
+ private Typeface mTabTypeface;
+ private int mTabTypefaceStyle = Typeface.BOLD;
+ private int mLastScrollX = 0;
+ private int mBackgroundResId = R.drawable.vpi__tab_background;
+ private Locale mLocale;
+
+ public StripPageIndicator(Context context) {
+ this(context, null);
+ }
+
+ public StripPageIndicator(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public StripPageIndicator(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setFillViewport(true);
+ setWillNotDraw(false);
+
+ mTabsContainer = new LinearLayout(context);
+ mTabsContainer.setOrientation(LinearLayout.HORIZONTAL);
+ mTabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ addView(mTabsContainer);
+
+ // Load defaults
+ final Resources res = getResources();
+ mIndicatorColor = res.getColor(R.color.default_strip_indicator_indicator_color);
+ mUnderlineColor = res.getColor(R.color.default_strip_indicator_divider_color);
+ mDividerColor = res.getColor(R.color.default_strip_indicator_divider_color);
+ mShouldExpand = res.getBoolean(R.bool.default_strip_indicator_should_expand);
+ mTextAllCaps = res.getBoolean(R.bool.default_strip_indicator_text_all_caps);
+ mScrollOffset = res.getDimensionPixelSize(R.dimen.default_strip_indicator_scroll_offset);
+ mIndicatorHeight = res.getDimensionPixelSize(R.dimen.default_strip_indicator_indicator_height);
+ mUnderlineHeight = res.getDimensionPixelSize(R.dimen.default_strip_indicator_underline_height);
+ mDividerPadding = res.getDimensionPixelSize(R.dimen.default_strip_indicator_divider_padding);
+ mTabPadding = res.getDimensionPixelSize(R.dimen.default_strip_indicator_tab_padding);
+ mDividerWidth = res.getDimensionPixelSize(R.dimen.default_strip_indicator_divider_width);
+ mTabTextSize = res.getDimensionPixelSize(R.dimen.default_strip_indicator_text_size);
+
+ // get system attrs (android:textSize and android:textColor)
+ TypedArray a = context.obtainStyledAttributes(attrs, ATTRS, defStyle, 0);
+ mTabTextSize = a.getDimensionPixelSize(0, mTabTextSize);
+ mTabTextColor = a.getColorStateList(1);
+ a.recycle();
+
+ if(mTabTextColor == null) {
+ mTabTextColor = res.getColorStateList(R.color.default_strip_indicator_text_color);
+ }
+
+ // get custom attrs
+ a = context.obtainStyledAttributes(attrs, R.styleable.StripPageIndicator);
+ mIndicatorColor = a.getColor(R.styleable.StripPageIndicator_vpiIndicatorColor, mIndicatorColor);
+ mUnderlineColor = a.getColor(R.styleable.StripPageIndicator_vpiUnderlineColor, mUnderlineColor);
+ mDividerColor = a.getColor(R.styleable.StripPageIndicator_vpiDividerColor, mDividerColor);
+ mIndicatorHeight = a.getDimensionPixelSize(R.styleable.StripPageIndicator_vpiIndicatorHeight, mIndicatorHeight);
+ mUnderlineHeight = a.getDimensionPixelSize(R.styleable.StripPageIndicator_vpiUnderlineHeight, mUnderlineHeight);
+ mDividerPadding = a.getDimensionPixelSize(R.styleable.StripPageIndicator_vpiDividerPadding, mDividerPadding);
+ mTabPadding = a.getDimensionPixelSize(R.styleable.StripPageIndicator_vpiTabPaddingLeftRight, mTabPadding);
+ mBackgroundResId = a.getResourceId(R.styleable.StripPageIndicator_vpiTabBackground, mBackgroundResId);
+ mShouldExpand = a.getBoolean(R.styleable.StripPageIndicator_vpiShouldExpand, mShouldExpand);
+ mScrollOffset = a.getDimensionPixelSize(R.styleable.StripPageIndicator_vpiScrollOffset, mScrollOffset);
+ mTextAllCaps = a.getBoolean(R.styleable.StripPageIndicator_vpiTextAllCaps, mTextAllCaps);
+ mTabTextSize = a.getDimensionPixelSize(R.styleable.StripPageIndicator_android_textSize, mTabTextSize);
+ ColorStateList textColor = a.getColorStateList(R.styleable.StripPageIndicator_android_textColor);
+ if (textColor != null) mTabTextColor = textColor;
+ a.recycle();
+
+ mRectPaint = new Paint();
+ mRectPaint.setAntiAlias(true);
+ mRectPaint.setStyle(Style.FILL);
+ mDividerPaint = new Paint();
+ mDividerPaint.setAntiAlias(true);
+ mDividerPaint.setStrokeWidth(mDividerWidth);
+ mDefaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
+ mExpandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
+ if (mLocale == null) {
+ mLocale = getResources().getConfiguration().locale;
+ }
+ }
+
+ public void setViewPager(ViewPager view) {
+ if (mViewPager == view) {
+ return;
+ }
+ if (view.getAdapter() == null) {
+ throw new IllegalStateException("ViewPager does not have adapter instance.");
+ }
+ this.mViewPager = view;
+ view.setOnPageChangeListener(this);
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public void setViewPager(ViewPager view, int initialPosition) {
+ setViewPager(view);
+ setCurrentItem(initialPosition);
+ }
+
+ @Override
+ public void setCurrentItem(int item) {
+ if (mViewPager == null) {
+ throw new IllegalStateException("ViewPager has not been bound.");
+ }
+ mViewPager.setCurrentItem(item);
+ mCurrentPage = item;
+ setTabSelected();
+ invalidate();
+ }
+
+ private void setTabSelected() {
+ for (int i = 0; i < mTabCount; i++) {
+ final View child = mTabsContainer.getChildAt(i);
+ child.setSelected(i == mCurrentPage);
+ }
+ }
+
+ public void setOnPageChangeListener(OnPageChangeListener listener) {
+ this.mListener = listener;
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ Log.d("OnPageScrolled", position + ":" + positionOffset +":" + positionOffsetPixels);
+ mLinePosition = position;
+ mCurrentPositionOffset = positionOffset;
+ scrollToChild(position, (int) (positionOffset * mTabsContainer.getChildAt(position).getWidth()));
+ invalidate();
+ if (mListener != null) {
+ mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
+ }
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ if (state == ViewPager.SCROLL_STATE_IDLE) {
+ scrollToChild(mViewPager.getCurrentItem(), 0);
+ }
+ if (mListener != null) {
+ mListener.onPageScrollStateChanged(state);
+ }
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ mCurrentPage = position;
+ // select the selected tab
+ setTabSelected();
+ if (mListener != null) {
+ mListener.onPageSelected(position);
+ }
+ }
+
+ public void notifyDataSetChanged() {
+ mTabsContainer.removeAllViews();
+ final PagerAdapter adapter = mViewPager.getAdapter();
+ mTabCount = adapter.getCount();
+ IconPagerAdapter iconAdapter = adapter instanceof IconPagerAdapter ? (IconPagerAdapter) adapter : null;
+
+ for (int i = 0; i < mTabCount; i++) {
+ if (iconAdapter != null) {
+ addIconTab(i, iconAdapter.getIconResId(i));
+ } else {
+ addTextTab(i, adapter.getPageTitle(i));
+ }
+ }
+ updateTabStyles();
+ getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
+ @SuppressWarnings("deprecation")
+ @SuppressLint("NewApi")
+ @Override
+ public void onGlobalLayout() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ getViewTreeObserver().removeGlobalOnLayoutListener(this);
+ } else {
+ getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+ mCurrentPage = mViewPager.getCurrentItem();
+ scrollToChild(mCurrentPage, 0);
+ setTabSelected();
+ }
+ });
+ }
+
+ private void addTextTab(final int position, CharSequence title) {
+ TextView tab = new TextView(getContext());
+ tab.setText(title);
+ tab.setGravity(Gravity.CENTER);
+ tab.setSingleLine();
+ addTab(position, tab);
+ }
+
+ private void addIconTab(final int position, int resId) {
+ ImageButton tab = new ImageButton(getContext());
+ tab.setImageResource(resId);
+ addTab(position, tab);
+ }
+
+ private void addTab(final int position, View tab) {
+ tab.setFocusable(true);
+ tab.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mViewPager.setCurrentItem(position);
+ }
+ });
+ tab.setPadding(mTabPadding, 0, mTabPadding, 0);
+ mTabsContainer.addView(tab, position, mShouldExpand ? mExpandedTabLayoutParams : mDefaultTabLayoutParams);
+ }
+
+ private void updateTabStyles() {
+ for (int i = 0; i < mTabCount; i++) {
+ View v = mTabsContainer.getChildAt(i);
+ v.setBackgroundResource(mBackgroundResId);
+ if (v instanceof TextView) {
+ TextView tab = (TextView) v;
+ tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
+ tab.setTypeface(mTabTypeface, mTabTypefaceStyle);
+ tab.setTextColor(mTabTextColor);
+ // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
+ // pre-ICS-build
+ if (mTextAllCaps) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ tab.setAllCaps(true);
+ } else {
+ tab.setText(tab.getText().toString().toUpperCase(mLocale));
+ }
+ }
+ }
+ }
+ }
+
+ private void scrollToChild(int position, int offset) {
+ if (mTabCount == 0) {
+ return;
+ }
+ int newScrollX = mTabsContainer.getChildAt(position).getLeft() + offset;
+ if (position > 0 || offset > 0) {
+ newScrollX -= mScrollOffset;
+ }
+ if (newScrollX != mLastScrollX) {
+ mLastScrollX = newScrollX;
+ scrollTo(newScrollX, 0);
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ if (isInEditMode() || mTabCount == 0) {
+ return;
+ }
+
+ final int height = getHeight();
+
+ // draw indicator line
+ mRectPaint.setColor(mIndicatorColor);
+
+ // default: line below current tab
+ View currentTab = mTabsContainer.getChildAt(mLinePosition);
+ float lineLeft = currentTab.getLeft();
+ float lineRight = currentTab.getRight();
+
+ // if there is an offset, start interpolating left and right coordinates between current and next tab
+ if (mCurrentPositionOffset > 0f && mLinePosition < mTabCount - 1) {
+ View nextTab = mTabsContainer.getChildAt(mLinePosition + 1);
+ final float nextTabLeft = nextTab.getLeft();
+ final float nextTabRight = nextTab.getRight();
+ lineLeft += (nextTabLeft - lineLeft) * mCurrentPositionOffset;
+ lineRight += (nextTabRight - lineRight) * mCurrentPositionOffset;
+ }
+
+ canvas.drawRect(lineLeft, height - mIndicatorHeight, lineRight, height, mRectPaint);
+ // draw underline
+ mRectPaint.setColor(mUnderlineColor);
+ canvas.drawRect(0, height - mUnderlineHeight, mTabsContainer.getWidth(), height, mRectPaint);
+ // draw divider
+ mDividerPaint.setColor(mDividerColor);
+ for (int i = 0; i < mTabCount - 1; i++) {
+ View tab = mTabsContainer.getChildAt(i);
+ canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint);
+ }
+ }
+
+ public void setIndicatorColor(int indicatorColor) {
+ this.mIndicatorColor = indicatorColor;
+ invalidate();
+ }
+
+ public void setIndicatorColorResource(int resId) {
+ this.mIndicatorColor = getResources().getColor(resId);
+ invalidate();
+ }
+
+ public int getIndicatorColor() {
+ return this.mIndicatorColor;
+ }
+
+ public void setIndicatorHeight(int indicatorLineHeightPx) {
+ this.mIndicatorHeight = indicatorLineHeightPx;
+ invalidate();
+ }
+
+ public int getIndicatorHeight() {
+ return mIndicatorHeight;
+ }
+
+ public void setUnderlineColor(int underlineColor) {
+ this.mUnderlineColor = underlineColor;
+ invalidate();
+ }
+
+ public void setUnderlineColorResource(int resId) {
+ this.mUnderlineColor = getResources().getColor(resId);
+ invalidate();
+ }
+
+ public int getUnderlineColor() {
+ return mUnderlineColor;
+ }
+
+ public void setDividerColor(int dividerColor) {
+ this.mDividerColor = dividerColor;
+ invalidate();
+ }
+
+ public void setDividerColorResource(int resId) {
+ this.mDividerColor = getResources().getColor(resId);
+ invalidate();
+ }
+
+ public int getDividerColor() {
+ return mDividerColor;
+ }
+
+ public void setUnderlineHeight(int underlineHeightPx) {
+ this.mUnderlineHeight = underlineHeightPx;
+ invalidate();
+ }
+
+ public int getUnderlineHeight() {
+ return mUnderlineHeight;
+ }
+
+ public void setDividerPadding(int dividerPaddingPx) {
+ this.mDividerPadding = dividerPaddingPx;
+ invalidate();
+ }
+
+ public int getDividerPadding() {
+ return mDividerPadding;
+ }
+
+ public void setScrollOffset(int scrollOffsetPx) {
+ this.mScrollOffset = scrollOffsetPx;
+ invalidate();
+ }
+
+ public int getScrollOffset() {
+ return mScrollOffset;
+ }
+
+ public void setShouldExpand(boolean shouldExpand) {
+ this.mShouldExpand = shouldExpand;
+ requestLayout();
+ }
+
+ public boolean getShouldExpand() {
+ return mShouldExpand;
+ }
+
+ public boolean isTextAllCaps() {
+ return mTextAllCaps;
+ }
+
+ public void setAllCaps(boolean textAllCaps) {
+ this.mTextAllCaps = textAllCaps;
+ }
+
+ public void setTextSize(int textSizePx) {
+ this.mTabTextSize = textSizePx;
+ updateTabStyles();
+ }
+
+ public int getTextSize() {
+ return mTabTextSize;
+ }
+
+ public void setTextColor(int textColor) {
+ this.mTabTextColor = ColorStateList.valueOf(textColor);
+ updateTabStyles();
+ }
+
+ public void setTextColorResource(int resId) {
+ this.mTabTextColor = getResources().getColorStateList(resId);
+ updateTabStyles();
+ }
+
+ public ColorStateList getTextColor() {
+ return mTabTextColor;
+ }
+
+ public void setTypeface(Typeface typeface, int style) {
+ this.mTabTypeface = typeface;
+ this.mTabTypefaceStyle = style;
+ updateTabStyles();
+ }
+
+ public void setTabBackground(int resId) {
+ this.mBackgroundResId = resId;
+ }
+
+ public int getTabBackground() {
+ return mBackgroundResId;
+ }
+
+ public void setTabPaddingLeftRight(int paddingPx) {
+ this.mTabPadding = paddingPx;
+ updateTabStyles();
+ }
+
+ public int getTabPaddingLeftRight() {
+ return mTabPadding;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState savedState = (SavedState) state;
+ super.onRestoreInstanceState(savedState.getSuperState());
+ mCurrentPage = savedState.currentPage;
+ requestLayout();
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState savedState = new SavedState(superState);
+ savedState.currentPage = mCurrentPage;
+ return savedState;
+ }
+
+ static class SavedState extends BaseSavedState {
+ int currentPage;
+
+ public SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ private SavedState(Parcel in) {
+ super(in);
+ currentPage = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeInt(currentPage);
+ }
+
+ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
+ @Override
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ @Override
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/library/src/com/viewpagerindicator/TabPageIndicator.java b/library/src/main/java/com/viewpagerindicator/TabPageIndicator.java
similarity index 78%
rename from library/src/com/viewpagerindicator/TabPageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/TabPageIndicator.java
index 1fceda3e0..96482ca73 100644
--- a/library/src/com/viewpagerindicator/TabPageIndicator.java
+++ b/library/src/main/java/com/viewpagerindicator/TabPageIndicator.java
@@ -17,6 +17,8 @@
package com.viewpagerindicator;
import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
@@ -35,9 +37,16 @@
* across different configurations or circumstances.
*/
public class TabPageIndicator extends HorizontalScrollView implements PageIndicator {
- /** Title text used when no title is provided by the adapter. */
+ /**
+ * Title text used when no title is provided by the adapter.
+ */
private static final CharSequence EMPTY_TITLE = "";
+ private static final int ICON_LEFT = 0;
+ private static final int ICON_RIGHT = 1;
+ private static final int ICON_TOP = 2;
+ private static final int ICON_BOTTOM = 3;
+
/**
* Interface for a callback when the selected tab has been reselected.
*/
@@ -54,7 +63,7 @@ public interface OnTabReselectedListener {
private final OnClickListener mTabClickListener = new OnClickListener() {
public void onClick(View view) {
- TabView tabView = (TabView)view;
+ TabView tabView = (TabView) view;
final int oldSelected = mViewPager.getCurrentItem();
final int newSelected = tabView.getIndex();
mViewPager.setCurrentItem(newSelected);
@@ -72,6 +81,10 @@ public void onClick(View view) {
private int mMaxTabWidth;
private int mSelectedTabIndex;
+ private int mIconDirection;
+ private int mIconWidth;
+ private int mIconHeight;
+
private OnTabReselectedListener mTabReselectedListener;
public TabPageIndicator(Context context) {
@@ -82,6 +95,12 @@ public TabPageIndicator(Context context, AttributeSet attrs) {
super(context, attrs);
setHorizontalScrollBarEnabled(false);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPageIndicator);
+ mIconDirection = a.getInteger(R.styleable.TabPageIndicator_vpi_iconDirection, ICON_LEFT);
+ mIconWidth = a.getDimensionPixelSize(R.styleable.TabPageIndicator_vpi_iconWidth, 0);
+ mIconHeight = a.getDimensionPixelSize(R.styleable.TabPageIndicator_vpi_iconHeight, 0);
+ a.recycle();
+
mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle);
addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
@@ -99,7 +118,7 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int childCount = mTabLayout.getChildCount();
if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
if (childCount > 2) {
- mMaxTabWidth = (int)(MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
+ mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
} else {
mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
}
@@ -157,7 +176,35 @@ private void addTab(int index, CharSequence text, int iconResId) {
tabView.setText(text);
if (iconResId != 0) {
- tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
+ Drawable icon = getResources().getDrawable(iconResId);
+ if (mIconWidth != 0) {
+ if (mIconHeight != 0) {// if icon width and height has be set
+ icon.setBounds(0, 0, mIconWidth, mIconHeight);
+ } else {// if only set the icon width, then scale the icon
+ icon.setBounds(0, 0, mIconWidth, mIconWidth * icon.getIntrinsicHeight() / icon.getIntrinsicWidth());
+ }
+ } else {
+ if (mIconHeight != 0) {
+ icon.setBounds(0, 0, mIconHeight * icon.getIntrinsicWidth() / icon.getIntrinsicHeight(), mIconHeight);
+ } else {
+ icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
+ }
+ }
+ switch (mIconDirection) {
+ case ICON_LEFT:
+ tabView.setCompoundDrawables(icon, null, null, null);
+ break;
+ case ICON_RIGHT:
+ tabView.setCompoundDrawables(null, null, icon, null);
+ break;
+ case ICON_TOP:
+ tabView.setCompoundDrawables(null, icon, null, null);
+ break;
+ case ICON_BOTTOM:
+ default:
+ tabView.setCompoundDrawables(null, null, null, icon);
+ }
+
}
mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
@@ -207,7 +254,7 @@ public void notifyDataSetChanged() {
PagerAdapter adapter = mViewPager.getAdapter();
IconPagerAdapter iconAdapter = null;
if (adapter instanceof IconPagerAdapter) {
- iconAdapter = (IconPagerAdapter)adapter;
+ iconAdapter = (IconPagerAdapter) adapter;
}
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
diff --git a/library/src/com/viewpagerindicator/TitlePageIndicator.java b/library/src/main/java/com/viewpagerindicator/TitlePageIndicator.java
similarity index 99%
rename from library/src/com/viewpagerindicator/TitlePageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/TitlePageIndicator.java
index f155d830a..1d2c97848 100644
--- a/library/src/com/viewpagerindicator/TitlePageIndicator.java
+++ b/library/src/main/java/com/viewpagerindicator/TitlePageIndicator.java
@@ -541,7 +541,7 @@ protected void onDraw(Canvas canvas) {
}
}
- public boolean onTouchEvent(android.view.MotionEvent ev) {
+ public boolean onTouchEvent(MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
}
@@ -847,7 +847,7 @@ public void writeToParcel(Parcel dest, int flags) {
}
@SuppressWarnings("UnusedDeclaration")
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
+ public static final Creator CREATOR = new Creator() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
diff --git a/library/src/com/viewpagerindicator/UnderlinePageIndicator.java b/library/src/main/java/com/viewpagerindicator/UnderlinePageIndicator.java
similarity index 100%
rename from library/src/com/viewpagerindicator/UnderlinePageIndicator.java
rename to library/src/main/java/com/viewpagerindicator/UnderlinePageIndicator.java
diff --git a/library/res/color/vpi__dark_theme.xml b/library/src/main/res/color/vpi__dark_theme.xml
similarity index 100%
rename from library/res/color/vpi__dark_theme.xml
rename to library/src/main/res/color/vpi__dark_theme.xml
diff --git a/library/res/color/vpi__light_theme.xml b/library/src/main/res/color/vpi__light_theme.xml
similarity index 100%
rename from library/res/color/vpi__light_theme.xml
rename to library/src/main/res/color/vpi__light_theme.xml
diff --git a/library/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
diff --git a/library/res/drawable-hdpi/vpi__tab_selected_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_selected_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_selected_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_selected_holo.9.png
diff --git a/library/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
diff --git a/library/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
diff --git a/library/res/drawable-hdpi/vpi__tab_unselected_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_unselected_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_unselected_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_unselected_holo.9.png
diff --git a/library/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png b/library/src/main/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
rename to library/src/main/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_selected_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_selected_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_selected_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_selected_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_unselected_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_unselected_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_unselected_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_unselected_holo.9.png
diff --git a/library/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png b/library/src/main/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
rename to library/src/main/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_selected_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_selected_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_selected_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_selected_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png
diff --git a/library/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png b/library/src/main/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
similarity index 100%
rename from library/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
rename to library/src/main/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
diff --git a/library/src/main/res/drawable/vpi__tab_background.xml b/library/src/main/res/drawable/vpi__tab_background.xml
new file mode 100644
index 000000000..70c8db888
--- /dev/null
+++ b/library/src/main/res/drawable/vpi__tab_background.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/res/drawable/vpi__tab_indicator.xml b/library/src/main/res/drawable/vpi__tab_indicator.xml
similarity index 100%
rename from library/res/drawable/vpi__tab_indicator.xml
rename to library/src/main/res/drawable/vpi__tab_indicator.xml
diff --git a/library/res/values/vpi__attrs.xml b/library/src/main/res/values/vpi__attrs.xml
similarity index 83%
rename from library/res/values/vpi__attrs.xml
rename to library/src/main/res/values/vpi__attrs.xml
index 8b1ccdb92..ac9aa21ab 100644
--- a/library/res/values/vpi__attrs.xml
+++ b/library/src/main/res/values/vpi__attrs.xml
@@ -128,4 +128,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/library/res/values/vpi__colors.xml b/library/src/main/res/values/vpi__colors.xml
similarity index 95%
rename from library/res/values/vpi__colors.xml
rename to library/src/main/res/values/vpi__colors.xml
index 62ca60704..428d9c0ce 100644
--- a/library/res/values/vpi__colors.xml
+++ b/library/src/main/res/values/vpi__colors.xml
@@ -23,4 +23,5 @@
#ffb2b2b2
@color/vpi__bright_foreground_holo_light
@color/vpi__bright_foreground_holo_dark
+ #6633B5E5
diff --git a/library/res/values/vpi__defaults.xml b/library/src/main/res/values/vpi__defaults.xml
similarity index 76%
rename from library/res/values/vpi__defaults.xml
rename to library/src/main/res/values/vpi__defaults.xml
index 327959597..a5642afb0 100644
--- a/library/res/values/vpi__defaults.xml
+++ b/library/src/main/res/values/vpi__defaults.xml
@@ -51,4 +51,18 @@
300
400
#FF33B5E5
+
+ #FF666666
+ #1A000000
+ #1A000000
+ false
+ true
+ 52dp
+ 8dp
+ 2dp
+ 12dp
+ 1dp
+ 16dp
+ 12sp
+ #FF666666
\ No newline at end of file
diff --git a/library/res/values/vpi__styles.xml b/library/src/main/res/values/vpi__styles.xml
similarity index 100%
rename from library/res/values/vpi__styles.xml
rename to library/src/main/res/values/vpi__styles.xml
diff --git a/sample/.gitignore b/sample/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/sample/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/sample/build.gradle b/sample/build.gradle
new file mode 100644
index 000000000..258e89cc9
--- /dev/null
+++ b/sample/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 22
+ buildToolsVersion '25.0.0'
+
+ defaultConfig {
+ applicationId "com.viewpagerindicator.sample"
+ minSdkVersion 4
+ targetSdkVersion 22
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile project(":library")
+}
diff --git a/sample/libs/android-support-v4.jar b/sample/libs/android-support-v4.jar
deleted file mode 100644
index 99e063b33..000000000
Binary files a/sample/libs/android-support-v4.jar and /dev/null differ
diff --git a/sample/proguard-rules.pro b/sample/proguard-rules.pro
new file mode 100644
index 000000000..ab2b42bac
--- /dev/null
+++ b/sample/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/gimbert/dev/android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/sample/src/androidTest/java/com/viewpagerindicator/sample/ApplicationTest.java b/sample/src/androidTest/java/com/viewpagerindicator/sample/ApplicationTest.java
new file mode 100644
index 000000000..08b23e6dc
--- /dev/null
+++ b/sample/src/androidTest/java/com/viewpagerindicator/sample/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.viewpagerindicator.sample;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/sample/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
similarity index 68%
rename from sample/AndroidManifest.xml
rename to sample/src/main/AndroidManifest.xml
index bbcb3afbe..4036cd32d 100644
--- a/sample/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -1,52 +1,45 @@
-
-
-
+ package="com.viewpagerindicator.sample">
+ android:icon="@mipmap/icon">
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+ android:name=".SampleLinesDefault"
+ android:label="Lines/Default">
-
-
+
+
+ android:name=".SampleLinesStyledLayout"
+ android:label="Lines/Styled (via layout)"
+ android:theme="@android:style/Theme.Light">
-
-
+
+
+ android:name=".SampleLinesStyledMethods"
+ android:label="Lines/Styled (via methods)"
+ android:theme="@android:style/Theme.Light">
-
-
+
+
+ android:name=".SampleLinesStyledTheme"
+ android:label="Lines/Styled (via theme)"
+ android:theme="@style/StyledIndicators">
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+ android:name=".SampleUnderlinesDefault"
+ android:label="Underlines/Default">
-
-
+
+
+ android:name=".SampleUnderlinesNoFade"
+ android:label="Underlines/No Fade">
-
-
+
+
+ android:name=".SampleUnderlinesStyledLayout"
+ android:label="Underlines/Styled (via layout)"
+ android:theme="@android:style/Theme.Light">
-
-
+
+
+ android:name=".SampleUnderlinesStyledMethods"
+ android:label="Underlines/Styled (via methods)"
+ android:theme="@android:style/Theme.Light">
-
-
+
+
+ android:name=".SampleUnderlinesStyledTheme"
+ android:label="Underlines/Styled (via theme)"
+ android:theme="@style/StyledIndicators">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample/src/com/viewpagerindicator/sample/BaseSampleActivity.java b/sample/src/main/java/com/viewpagerindicator/sample/BaseSampleActivity.java
similarity index 100%
rename from sample/src/com/viewpagerindicator/sample/BaseSampleActivity.java
rename to sample/src/main/java/com/viewpagerindicator/sample/BaseSampleActivity.java
diff --git a/sample/src/com/viewpagerindicator/sample/ListSamples.java b/sample/src/main/java/com/viewpagerindicator/sample/ListSamples.java
similarity index 97%
rename from sample/src/com/viewpagerindicator/sample/ListSamples.java
rename to sample/src/main/java/com/viewpagerindicator/sample/ListSamples.java
index c175e8e1c..eb37a8e17 100644
--- a/sample/src/com/viewpagerindicator/sample/ListSamples.java
+++ b/sample/src/main/java/com/viewpagerindicator/sample/ListSamples.java
@@ -1,132 +1,132 @@
-package com.viewpagerindicator.sample;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import android.app.ListActivity;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-
-public class ListSamples extends ListActivity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Intent intent = getIntent();
- String path = intent.getStringExtra("com.jakewharton.android.viewpagerindicator.sample.Path");
-
- if (path == null) {
- path = "";
- }
-
- setListAdapter(new SimpleAdapter(this, getData(path),
- android.R.layout.simple_list_item_1, new String[] { "title" },
- new int[] { android.R.id.text1 }));
- getListView().setTextFilterEnabled(true);
- }
-
- protected List