Skip to content

Commit

Permalink
Fixes bug if recyclerview is empty. Adds 0 as an item quantity choice…
Browse files Browse the repository at this point in the history
… to sample app to test empty RV
  • Loading branch information
Ryan Brooks authored and Ryan Brooks committed Jan 14, 2018
1 parent d30593b commit 2311872
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -230,7 +230,7 @@ class IndefinitePagerIndicator @JvmOverloads constructor(context: Context, attrs
offsetPercent = positionOffset * -1
invalidate()
}

override fun onPageSelected(position: Int) {
intermediateSelectedItemPosition = selectedItemPosition
selectedItemPosition = position
Expand Down Expand Up @@ -264,8 +264,11 @@ class IndefinitePagerIndicator @JvmOverloads constructor(context: Context, attrs
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {

val view = getMostVisibleChild()
setIntermediateSelectedItemPosition(view)
offsetPercent = view!!.left.toFloat() / view.measuredWidth

if (view != null) {
setIntermediateSelectedItemPosition(view)
offsetPercent = view.left.toFloat() / view.measuredWidth
}

val layoutManager = recyclerView?.layoutManager as LinearLayoutManager
val visibleItemPosition = if (dx >= 0) layoutManager.findLastVisibleItemPosition() else layoutManager.findFirstVisibleItemPosition()
Expand Down
Expand Up @@ -16,7 +16,7 @@ class PagerNumberPickerDialogPreference : DialogFragment() {
companion object {
val KEY_NUM_PAGES = "num_pages"

val MIN_PAGES = 1
val MIN_PAGES = 0
val MAX_PAGES = PhotoItem.values().size
val DEFAULT_PAGES = 3
}
Expand Down

0 comments on commit 2311872

Please sign in to comment.