aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
new file mode 100644
index 0000000..cca35b0
--- /dev/null
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
@@ -0,0 +1,35 @@
+package ca.allanwang.kau.kpref.items
+
+import android.support.annotation.StringRes
+import android.view.View
+import ca.allanwang.kau.R
+import ca.allanwang.kau.dialogs.color.colorPickerDialog
+import com.mikepenz.iconics.typeface.IIcon
+
+/**
+ * Created by Allan Wang on 2017-06-07.
+ */
+class KPrefColorPicker(@StringRes title: Int,
+ @StringRes description: Int = -1,
+ iicon: IIcon? = null,
+ enabled: Boolean = true,
+ getter: () -> Int,
+ setter: (value: Int) -> Unit) : KPrefItemBase<Int>(title, description, iicon, enabled, getter, setter) {
+
+ override fun onPostBindView(viewHolder: KPrefItemCore.ViewHolder) {
+ super.onPostBindView(viewHolder)
+ //TODO add color circle view
+ }
+
+ override fun onClick(itemView: View): Boolean {
+ itemView.context.colorPickerDialog {
+ titleRes = this@KPrefColorPicker.title
+ defaultColor = pref
+ colorCallbacks.add { pref = it }
+ }.show()
+ return true
+ }
+
+ override fun getType(): Int = R.id.kau_item_pref_color_picker
+
+} \ No newline at end of file