Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Zero Count #19

Merged
merged 4 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ android:
- tools
- platform-tools
- build-tools-27.0.3
- android-27
- android-28
- extra-google-m2repository
- extra-android-m2repository
licenses:
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

before_install:
- echo yes | sdkmanager "platforms;android-27"
- echo yes | sdkmanager "platforms;android-28"

script:
- ./gradlew clean build -PdisablePreDex --stacktrace --console plain
Expand Down
17 changes: 10 additions & 7 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
ext {
// Android Version
minSdkVersion = 14
compileSdkVersion = 27
targetSdkVersion = 27
gradleVersion = '3.1.1'
kotlinVersion = '1.2.40'
compileSdkVersion = 28
targetSdkVersion = 28
gradleVersion = '3.1.4'
kotlinVersion = '1.2.61'

supportLibraryVersion = '27.1.1'

// Kotlin
kotlinStdlib = 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:' + kotlinVersion

def groupId = 'com.android.support'
animatedVectorDrawable = groupId + ':animated-vector-drawable:' + supportLibraryVersion
appcompatV7 = groupId + ':appcompat-v7:' + supportLibraryVersion
cardView = groupId + ':cardview-v7:' + supportLibraryVersion
design = groupId + ':design:' + supportLibraryVersion
exifinterface = groupId + ':exifinterface:' + supportLibraryVersion
recyclerviewV7 = groupId + ':recyclerview-v7:' + supportLibraryVersion
supportAnnotations = groupId + ':support-annotations:' + supportLibraryVersion
constraintLayout = groupId + '.constraint:constraint-layout:1.1.0'

picasso = 'com.squareup.picasso:picasso:2.71828'

picasso = 'com.squareup.picasso:picasso:2.6.0-SNAPSHOT'

supportLibs = [appcompatV7,
supportLibs = [animatedVectorDrawable,
appcompatV7,
cardView,
design,
exifinterface,
recyclerviewV7,
supportAnnotations,
constraintLayout]
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-4.9-all.zip
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-4.6-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ internal class DotManager(
private val targetScrollListener: TargetScrollListener? = null
) {

internal var dots: ByteArray
internal var dots: ByteArray = ByteArray(count)
internal var selectedIndex = 0

private var scrollAmount = 0

init {
if (count <= 0) {
throw IllegalArgumentException("count expected to be > 0, actual: $count")

if (count > 0) {
dots[0] = 6
}

dots = ByteArray(count)
dots[0] = 6
if (count <= SIZE_THRESHOLD) {
(1 until count).forEach { i -> dots[i] = 5 }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,26 @@ class PageIndicator @JvmOverloads constructor(
private var scrollListener: RecyclerView.OnScrollListener? = null
private var pageChangeListener: ViewPager.OnPageChangeListener? = null

private var _count = 0
var count: Int
var count: Int = 0
set(value) {
_count = value
dotManager = DotManager(
_count,
value,
dotSize,
dotSpacing,
dotBound,
dotSizeMap,
this)

dotSizes = IntArray(_count)
dotSizes = IntArray(value)
dotManager?.let { it.dots.forEachIndexed { index, dot -> dotSizes[index] = it.dotSizeFor(dot) } }
dotAnimators = Array(_count, { _ -> ValueAnimator() })
dotAnimators = Array(value) { ValueAnimator() }

initialPadding = when (count) {
in 1..4 -> (dotBound + (4 - count) * (dotSize + dotSpacing) + dotSpacing) / 2
initialPadding = when (value) {
in 0..4 -> (dotBound + (4 - value) * (dotSize + dotSpacing) + dotSpacing) / 2
else -> 2 * (dotSize + dotSpacing)
}
invalidate()
}
get() = _count

init {
val ta = getContext().obtainStyledAttributes(attrs, R.styleable.PageIndicator)
Expand Down