Skip to content

Commit

Permalink
crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravindu committed Jun 24, 2018
1 parent 17c7e72 commit 186afe7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -134,48 +134,53 @@ class ViewPagerIndicator : LinearLayout, ViewPager.OnPageChangeListener, ViewPag
val num = childCount

for (i in 0 until num) {
val img = getChildAt(i) as ImageView
val img = getChildAt(i) as ImageView?

img?.let {
if (mAnimate) {
img.clearAnimation()

img.animate()
.scaleX(1f)
.scaleY(1f)
.setDuration(mAnimationDuration.toLong())
.start()
}


img.clearColorFilter()

if (mDeselectedDrawable != -1) {
img.setImageResource(mDeselectedDrawable)
} else if (mSelectedDrawable != -1) {
img.setImageResource(mSelectedDrawable)
img.colorFilter = LightingColorFilter(0, mDeselectedColor)
} else {
img.setImageResource(R.drawable.circle_drawable)
img.colorFilter = LightingColorFilter(0, mDeselectedColor)
}
}
}

val selectedView = getChildAt(selected) as ImageView?
selectedView?.let {
if (mAnimate) {
img.clearAnimation()

img.animate()
.scaleX(1f)
.scaleY(1f)
selectedView.animate()
.scaleX(mAnimScaleMultiplier)
.scaleY(mAnimScaleMultiplier)
.setDuration(mAnimationDuration.toLong())
.start()
}


img.clearColorFilter()

if (mDeselectedDrawable != -1) {
img.setImageResource(mDeselectedDrawable)
} else if (mSelectedDrawable != -1) {
img.setImageResource(mSelectedDrawable)
img.colorFilter = LightingColorFilter(0, mDeselectedColor)
if (mSelectedDrawable != -1) {
selectedView.clearColorFilter()
selectedView.setImageResource(mSelectedDrawable)
} else {
img.setImageResource(R.drawable.circle_drawable)
img.colorFilter = LightingColorFilter(0, mDeselectedColor)
selectedView.colorFilter = LightingColorFilter(0, mSelectedColor)
}
}

val selectedView = getChildAt(selected) as ImageView

if (mAnimate) {
selectedView.animate()
.scaleX(mAnimScaleMultiplier)
.scaleY(mAnimScaleMultiplier)
.setDuration(mAnimationDuration.toLong())
.start()
}

if (mSelectedDrawable != -1) {
selectedView.clearColorFilter()
selectedView.setImageResource(mSelectedDrawable)
} else {
selectedView.colorFilter = LightingColorFilter(0, mSelectedColor)
}
}


Expand Down

0 comments on commit 186afe7

Please sign in to comment.