Skip to content
Open
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: 4 additions & 0 deletions demo/src/main/java/com/super_rabbit/demo/DemoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.super_rabbit.demo

import android.graphics.Typeface
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import com.super_rabbit.demo.wheel_picker_adapters.WPDayPickerAdapter
Expand Down Expand Up @@ -95,5 +96,8 @@ class DemoActivity : AppCompatActivity() {
numberPicker.setTypeface(currentTypeFace)
numberPicker.reset()
}
get_selected.setOnClickListener {
Toast.makeText(context, "index=${numberPicker.getCurrentIndex()}, text=${numberPicker.getCurrentItem()}", Toast.LENGTH_SHORT).show()
}
}
}
9 changes: 9 additions & 0 deletions demo/src/main/res/layout/activity_normal_number_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="set picker typeface (current = serif)"
app:layout_constraintBottom_toTopOf="@+id/get_selected"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/get_selected"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="get picker selected"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ class WheelPicker @JvmOverloads constructor(
}

fun setUnselectedTextColor(resourceId: Int) {
mUnSelectedTextColor = resourceId
mUnSelectedTextColor = ContextCompat.getColor(context, resourceId)
}

/**
Expand Down Expand Up @@ -871,6 +871,15 @@ class WheelPicker @JvmOverloads constructor(
return getValue(mCurSelectedItemIndex)
}

/**
* Gets current selected index
*
* @return current index which is selected by wheel
* */
fun getCurrentIndex(): Int {
return mCurSelectedItemIndex
}

fun isValidPosition(position: Int): Boolean {
return when {
mMinValidIndex != null && position < mMinValidIndex!! -> false
Expand Down