diff options
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt deleted file mode 100644 index 762bcf4..0000000 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt +++ /dev/null @@ -1,73 +0,0 @@ -package ca.allanwang.kau.kpref.items - -import android.view.View -import ca.allanwang.kau.R -import ca.allanwang.kau.dialogs.color.CircleView -import ca.allanwang.kau.dialogs.color.ColorBuilder -import ca.allanwang.kau.dialogs.color.ColorContract -import ca.allanwang.kau.dialogs.color.colorPickerDialog -import ca.allanwang.kau.kpref.CoreAttributeContract -import ca.allanwang.kau.kpref.GlobalOptions -import ca.allanwang.kau.kpref.KPrefMarker - -/** - * Created by Allan Wang on 2017-06-07. - * - * ColorPicker preference - * When a color is successfully selected in the dialog, it will be saved as an int - */ -open class KPrefColorPicker(val builder: KPrefColorContract) : KPrefItemBase<Int>(builder) { - - override fun onPostBindView(viewHolder: ViewHolder, textColor: Int?, accentColor: Int?) { - super.onPostBindView(viewHolder, textColor, accentColor) - builder.apply { - titleRes = core.titleRes - colorCallback = { - pref = it - } - } - if (builder.showPreview) { - val preview = viewHolder.bindInnerView<CircleView>(R.layout.kau_preference_color_preview) - preview.setBackgroundColor(pref) - preview.withBorder = true - builder.apply { - colorCallback = { - pref = it - if (builder.showPreview) - preview.setBackgroundColor(it) - } - } - } - } - - - override fun defaultOnClick(itemView: View, innerContent: View?): Boolean { - builder.apply { - defaultColor = pref //update color - } - itemView.context.colorPickerDialog(builder).show() - return true - } - - /** - * Extension of the base contract and [ColorContract] along with a showPreview option - */ - interface KPrefColorContract : BaseContract<Int>, ColorContract { - var showPreview: Boolean - } - - /** - * Default implementation of [KPrefColorContract] - */ - class KPrefColorBuilder(globalOptions: GlobalOptions, - override var titleRes: Int, - getter: () -> Int, - setter: (value: Int) -> Unit - ) : KPrefColorContract, BaseContract<Int> by BaseBuilder<Int>(globalOptions, titleRes, getter, setter), - ColorContract by ColorBuilder() { - override var showPreview: Boolean = true - } - - override fun getType(): Int = R.id.kau_item_pref_color_picker - -}
\ No newline at end of file |