From 63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 18:59:14 -0700 Subject: Fix compile errors --- .../ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 13 ++++++++++--- .../allanwang/kau/kpref/activity/items/KPrefCheckbox.kt | 5 +++-- .../kau/kpref/activity/items/KPrefColorPicker.kt | 10 ++++++---- .../allanwang/kau/kpref/activity/items/KPrefHeader.kt | 8 +++++--- .../allanwang/kau/kpref/activity/items/KPrefItemBase.kt | 8 +++++--- .../allanwang/kau/kpref/activity/items/KPrefItemCore.kt | 4 ++-- .../kau/kpref/activity/items/KPrefPlainText.kt | 3 ++- .../allanwang/kau/kpref/activity/items/KPrefSeekbar.kt | 11 +++++++---- .../allanwang/kau/kpref/activity/items/KPrefSubItems.kt | 6 ++++-- .../ca/allanwang/kau/kpref/activity/items/KPrefText.kt | 8 +++++--- .../kau/kpref/activity/items/KPrefTimePicker.kt | 17 +++++++++++++---- 11 files changed, 62 insertions(+), 31 deletions(-) (limited to 'kpref-activity') diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt index b701a07..f11afde 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt @@ -32,6 +32,7 @@ import ca.allanwang.kau.utils.resolveColor import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter +import com.mikepenz.fastadapter.select.getSelectExtension import kotlinx.android.synthetic.main.kau_pref_activity.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -82,7 +83,8 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { toolbar.setNavigationOnClickListener { onBackPressed() } setDisplayShowTitleEnabled(false) } - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + window.decorView.systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN statusBarColor = 0x30000000 kau_toolbar_ripple.set(resolveColor(R.attr.colorPrimary)) kau_ripple.set(resolveColor(android.R.attr.colorBackground)) @@ -92,8 +94,13 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { core.builder() globalOptions = GlobalOptions(core, this) kau_recycler.withLinearAdapter(adapter) - adapter.withSelectable(false) - .withOnClickListener { v, _, item, _ -> item.onClick(v!!); true } + adapter.apply { + getSelectExtension().isSelectable = true + onClickListener = { v, _, item, _ -> + item.onClick(v!!) + true + } + } showNextPrefs(R.string.kau_settings, onCreateKPrefs(savedInstanceState), true) } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt index 0f025a6..f4f4a65 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt @@ -34,7 +34,7 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val checkbox = holder.bindInnerView(R.layout.kau_pref_checkbox) withAccentColor(checkbox::tint) @@ -42,5 +42,6 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase(builder) { - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) if (builder.showPreview) { val preview = holder.bindInnerView(R.layout.kau_pref_color) @@ -63,7 +63,7 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas /** * Extension of the base contract and [ColorContract] along with a showPreview option */ - interface KPrefColorContract : KPrefItemBase.BaseContract, ColorContract { + interface KPrefColorContract : BaseContract, ColorContract { var showPreview: Boolean var dialogBuilder: MaterialDialog.() -> Unit } @@ -76,11 +76,13 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefColorContract, KPrefItemBase.BaseContract by BaseBuilder(globalOptions, titleId, getter, setter), + ) : KPrefColorContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter), ColorContract by ColorBuilder() { override var showPreview: Boolean = true override var dialogBuilder: MaterialDialog.() -> Unit = {} } - override fun getType(): Int = R.id.kau_item_pref_color_picker + override val type: Int + get() = R.id.kau_item_pref_color_picker } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt index 7d73322..ca70b61 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt @@ -25,12 +25,14 @@ import ca.allanwang.kau.kpref.activity.R */ open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) { - override fun getLayoutRes(): Int = R.layout.kau_pref_header + override val layoutRes: Int + get() = R.layout.kau_pref_header - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) withAccentColor(holder.title::setTextColor) } - override fun getType() = R.id.kau_item_pref_header + override val type: Int + get() = R.id.kau_item_pref_header } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt index c597b63..9197057 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt @@ -46,7 +46,7 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem } @CallSuper - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) _enabled = base.enabler() with(holder) { @@ -77,12 +77,14 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem super.unbindView(holder) holder.container?.apply { isEnabled = true - background = holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) + background = + holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) alpha = 1.0f } } - final override fun getLayoutRes(): Int = R.layout.kau_pref_core + final override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the core contract diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt index 36bf670..79b7e82 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt @@ -48,7 +48,7 @@ import com.mikepenz.iconics.typeface.IIcon * Core class containing nothing but the view items */ -abstract class KPrefItemCore(val core: CoreContract) : AbstractItem(), KPrefItemActions by core, +abstract class KPrefItemCore(val core: CoreContract) : AbstractItem(), KPrefItemActions by core, ThemableIItem by ThemableIItemDelegate() { final override fun getViewHolder(v: View) = ViewHolder(v) @@ -70,7 +70,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) with(holder) { updateTitle() diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt index 6a0aaf5..7381a07 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt @@ -36,5 +36,6 @@ open class KPrefPlainText(open val builder: KPrefPlainTextBuilder) : KPrefItemBa titleId: Int ) : BaseContract by BaseBuilder(globalOptions, titleId, {}, {}) - override fun getType(): Int = R.id.kau_item_pref_plain_text + override val type: Int + get() = R.id.kau_item_pref_plain_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt index a582ec4..5de1f83 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt @@ -37,7 +37,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( override fun KClick.defaultOnClick() = Unit - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val text = holder.bindInnerView(R.layout.kau_pref_seekbar_text) withTextColor(text::setTextColor) @@ -60,7 +60,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( }) } withAccentColor(seekbar::tint) - text.text = builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs + text.text = + builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs seekbar.progress = pref.toProgress seekbar.isEnabled = builder.enabler() } @@ -87,7 +88,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefSeekbarContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefSeekbarContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var min: Int = 0 @@ -118,5 +120,6 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( protected inline val Int.fromProgress: Int get() = this * increment + min - override fun getType(): Int = R.id.kau_item_pref_seekbar + override val type: Int + get() = R.id.kau_item_pref_seekbar } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt index 1fa528b..8474627 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt @@ -33,7 +33,8 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor builder.globalOptions.showNextPrefs(builder.titleFun(), builder.itemBuilder) } - override fun getLayoutRes(): Int = R.layout.kau_pref_core + override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the base contract with an optional text getter @@ -51,5 +52,6 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor override val itemBuilder: KPrefAdapterBuilder.() -> Unit ) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleId) - override fun getType(): Int = R.id.kau_item_pref_sub_item + override val type: Int + get() = R.id.kau_item_pref_sub_item } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt index 76c9e20..50f0c62 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt @@ -46,7 +46,7 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< context.toast("No click function set") } - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val textView = holder.bindInnerView(R.layout.kau_pref_text) withTextColor(textView::setTextColor) @@ -68,9 +68,11 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< titleId: Int, getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit - ) : KPrefTextContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTextContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var textGetter: (T) -> String? = { it?.toString() } } - override fun getType(): Int = R.id.kau_item_pref_text + override val type: Int + get() = R.id.kau_item_pref_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt index f50397c..318b630 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt @@ -33,7 +33,8 @@ import java.util.Locale */ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText(builder) { - interface KPrefTimeContract : KPrefText.KPrefTextContract, TimePickerDialog.OnTimeSetListener { + interface KPrefTimeContract : KPrefText.KPrefTextContract, + TimePickerDialog.OnTimeSetListener { var use24HourFormat: Boolean } @@ -50,7 +51,8 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefTimeContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTimeContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var use24HourFormat: Boolean = false @@ -64,11 +66,18 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< if (use24HourFormat) String.format(Locale.CANADA, "%d:%02d", hour, min) else - String.format(Locale.CANADA, "%d:%02d %s", hour % 12, min, if (hour >= 12) "PM" else "AM") + String.format( + Locale.CANADA, + "%d:%02d %s", + hour % 12, + min, + if (hour >= 12) "PM" else "AM" + ) } } - override fun getType(): Int = R.id.kau_item_pref_time_picker + override val type: Int + get() = R.id.kau_item_pref_time_picker } private val Int.splitTime: Pair -- cgit v1.2.3