aboutsummaryrefslogtreecommitdiff
path: root/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:17:31 -0500
committerGitHub <noreply@github.com>2018-12-24 01:17:31 -0500
commitfb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b (patch)
treecc6d67461b6caa256043b9482f7646831d528a08 /kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items
parenta380adea1052d39f23c9c4d432a9380ce347d6c4 (diff)
downloadkau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.gz
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.bz2
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.zip
Enhancement/ktlint (#179)
* Add spotless dependency * Apply ktlint * Add license headers
Diffstat (limited to 'kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items')
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt20
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt29
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt18
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt29
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt56
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt22
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt26
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt24
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt26
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt29
10 files changed, 215 insertions, 64 deletions
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 0a7922e..0f025a6 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
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
-import androidx.appcompat.widget.AppCompatCheckBox
import android.widget.CheckBox
+import androidx.appcompat.widget.AppCompatCheckBox
import ca.allanwang.kau.kpref.activity.KClick
import ca.allanwang.kau.kpref.activity.R
import ca.allanwang.kau.utils.tint
@@ -28,5 +43,4 @@ open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean
}
override fun getType(): Int = R.id.kau_item_pref_checkbox
-
-} \ No newline at end of file
+}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
index 3201fbd..675e387 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import ca.allanwang.kau.colorpicker.CircleView
@@ -53,15 +68,15 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas
/**
* Default implementation of [KPrefColorContract]
*/
- class KPrefColorBuilder(globalOptions: GlobalOptions,
- titleId: Int,
- getter: () -> Int,
- setter: (value: Int) -> Unit
+ class KPrefColorBuilder(
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ getter: () -> Int,
+ setter: (value: Int) -> Unit
) : KPrefColorContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter),
- ColorContract by ColorBuilder() {
+ 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
+}
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 9b63a52..7d73322 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import ca.allanwang.kau.kpref.activity.R
@@ -18,5 +33,4 @@ open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) {
}
override fun getType() = R.id.kau_item_pref_header
-
-} \ No newline at end of file
+}
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 aa60fcd..6690574 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
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
-import androidx.annotation.CallSuper
import android.view.View
+import androidx.annotation.CallSuper
import ca.allanwang.kau.kpref.activity.GlobalOptions
import ca.allanwang.kau.kpref.activity.KClick
import ca.allanwang.kau.kpref.activity.R
@@ -84,14 +99,14 @@ abstract class KPrefItemBase<T>(protected val base: BaseContract<T>) : KPrefItem
/**
* Default implementation of [BaseContract]
*/
- class BaseBuilder<T>(globalOptions: GlobalOptions,
- titleId: Int,
- override val getter: () -> T,
- override val setter: (value: T) -> Unit
+ class BaseBuilder<T>(
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ override val getter: () -> T,
+ override val setter: (value: T) -> Unit
) : CoreContract by CoreBuilder(globalOptions, titleId), BaseContract<T> {
override var enabler: () -> Boolean = { true }
override var onClick: (KClick<T>.() -> Unit)? = null
override var onDisabledClick: (KClick<T>.() -> Unit)? = null
}
-
-} \ No newline at end of file
+}
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 4e8ecbe..fc632ce 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
@@ -1,23 +1,43 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import android.annotation.SuppressLint
-import androidx.annotation.CallSuper
-import androidx.annotation.IdRes
-import androidx.annotation.LayoutRes
-import androidx.annotation.StringRes
-import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
+import androidx.annotation.CallSuper
+import androidx.annotation.IdRes
+import androidx.annotation.LayoutRes
+import androidx.annotation.StringRes
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.kpref.activity.GlobalOptions
import ca.allanwang.kau.kpref.activity.KPrefMarker
import ca.allanwang.kau.kpref.activity.R
-import ca.allanwang.kau.utils.*
+import ca.allanwang.kau.utils.INVALID_ID
+import ca.allanwang.kau.utils.adjustAlpha
+import ca.allanwang.kau.utils.buildIsLollipopAndUp
+import ca.allanwang.kau.utils.gone
+import ca.allanwang.kau.utils.setIcon
+import ca.allanwang.kau.utils.visible
import com.mikepenz.fastadapter.items.AbstractItem
import com.mikepenz.iconics.typeface.IIcon
@@ -28,7 +48,7 @@ import com.mikepenz.iconics.typeface.IIcon
*/
abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCore, KPrefItemCore.ViewHolder>(),
- ThemableIItem by ThemableIItemDelegate() {
+ ThemableIItem by ThemableIItemDelegate() {
final override fun getViewHolder(v: View) = ViewHolder(v)
@@ -69,13 +89,15 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
}
protected inline fun withAccentColor(action: (color: Int) -> Unit) =
- withColor(core.globalOptions.accentColor, action)
+ withColor(core.globalOptions.accentColor, action)
protected inline fun withTextColor(action: (color: Int) -> Unit) =
- withColor(core.globalOptions.textColor, action)
+ withColor(core.globalOptions.textColor, action)
- protected inline fun withColor(noinline supplier: (() -> Int)?,
- action: (color: Int) -> Unit) {
+ protected inline fun withColor(
+ noinline supplier: (() -> Int)?,
+ action: (color: Int) -> Unit
+ ) {
val color = supplier?.invoke() ?: return
action(color)
}
@@ -116,8 +138,10 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
/**
* Default implementation of [CoreContract]
*/
- class CoreBuilder(override val globalOptions: GlobalOptions,
- override val titleId: Int) : CoreContract {
+ class CoreBuilder(
+ override val globalOptions: GlobalOptions,
+ override val titleId: Int
+ ) : CoreContract {
override var descRes: Int = INVALID_ID
set(value) {
field = value
@@ -149,7 +173,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
inline fun <reified T : View> bindInnerView(@LayoutRes id: Int, onFirstBind: (T) -> Unit): T {
val innerFrame = this.innerFrame
- ?: throw IllegalStateException("Cannot bind inner view when innerFrame does not exist")
+ ?: throw IllegalStateException("Cannot bind inner view when innerFrame does not exist")
if (innerView !is T) {
innerFrame.removeAllViews()
LayoutInflater.from(innerFrame.context).inflate(id, innerFrame)
@@ -162,7 +186,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
inline fun <reified T : View> bindLowerView(@LayoutRes id: Int, onFirstBind: (T) -> Unit): T {
val lowerFrame = this.lowerFrame
- ?: throw IllegalStateException("Cannot bind inner view when lowerContent does not exist")
+ ?: throw IllegalStateException("Cannot bind inner view when lowerContent does not exist")
if (lowerContent !is T) {
lowerFrame.removeAllViews()
LayoutInflater.from(lowerFrame.context).inflate(id, lowerFrame)
@@ -173,4 +197,4 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
operator fun get(@IdRes id: Int): View = itemView.findViewById(id)
}
-} \ No newline at end of file
+}
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 40bf284..6a0aaf5 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import ca.allanwang.kau.kpref.activity.GlobalOptions
@@ -17,10 +32,9 @@ open class KPrefPlainText(open val builder: KPrefPlainTextBuilder) : KPrefItemBa
override fun KClick<Unit>.defaultOnClick() = Unit
class KPrefPlainTextBuilder(
- globalOptions: GlobalOptions,
- titleId: Int
+ globalOptions: GlobalOptions,
+ titleId: Int
) : BaseContract<Unit> by BaseBuilder(globalOptions, titleId, {}, {})
override fun getType(): Int = R.id.kau_item_pref_plain_text
-
-} \ No newline at end of file
+}
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 ce61e8f..e70a374 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import android.widget.SeekBar
@@ -67,10 +82,10 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
* Default implementation of [KPrefSeekbarContract]
*/
class KPrefSeekbarBuilder(
- globalOptions: GlobalOptions,
- titleId: Int,
- getter: () -> Int,
- setter: (value: Int) -> Unit
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ getter: () -> Int,
+ setter: (value: Int) -> Unit
) : KPrefSeekbarContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) {
override var min: Int = 0
@@ -103,5 +118,4 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
get() = this * increment + min
override fun getType(): Int = R.id.kau_item_pref_seekbar
-
-} \ No newline at end of file
+}
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 6753142..1fa528b 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import android.view.View
@@ -31,11 +46,10 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor
* Default implementation of [KPrefTextContract]
*/
class KPrefSubItemsBuilder(
- globalOptions: GlobalOptions,
- titleId: Int,
- override val itemBuilder: KPrefAdapterBuilder.() -> Unit
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ override val itemBuilder: KPrefAdapterBuilder.() -> Unit
) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleId)
override fun getType(): Int = R.id.kau_item_pref_sub_item
-
-} \ No newline at end of file
+}
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 2ab911b..ac8416d 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import android.widget.TextView
@@ -48,14 +63,13 @@ open class KPrefText<T>(open val builder: KPrefTextContract<T>) : KPrefItemBase<
* Default implementation of [KPrefTextContract]
*/
class KPrefTextBuilder<T>(
- globalOptions: GlobalOptions,
- titleId: Int,
- getter: () -> T,
- setter: (value: T) -> Unit
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ getter: () -> T,
+ setter: (value: T) -> Unit
) : KPrefTextContract<T>, BaseContract<T> by BaseBuilder<T>(globalOptions, titleId, getter, setter) {
override var textGetter: (T) -> String? = { it?.toString() }
}
override fun getType(): Int = R.id.kau_item_pref_text
-
-} \ No newline at end of file
+}
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 f6fc40a..7242bbe 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
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.kpref.activity.items
import android.app.TimePickerDialog
@@ -5,7 +20,7 @@ import android.widget.TimePicker
import ca.allanwang.kau.kpref.activity.GlobalOptions
import ca.allanwang.kau.kpref.activity.KClick
import ca.allanwang.kau.kpref.activity.R
-import java.util.*
+import java.util.Locale
/**
* Created by Allan Wang on 2017-06-14.
@@ -30,10 +45,10 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<
* Default implementation of [KPrefTimeContract]
*/
class KPrefTimeBuilder(
- globalOptions: GlobalOptions,
- titleId: Int,
- getter: () -> Int,
- setter: (value: Int) -> Unit
+ globalOptions: GlobalOptions,
+ titleId: Int,
+ getter: () -> Int,
+ setter: (value: Int) -> Unit
) : KPrefTimeContract, BaseContract<Int> by BaseBuilder<Int>(globalOptions, titleId, getter, setter) {
override var use24HourFormat: Boolean = false
@@ -50,15 +65,13 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<
else
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
-
}
private val Int.splitTime: Pair<Int, Int>
get() = Pair(this / 100, this % 100)
private val Pair<Int, Int>.mergeTime: Int
- get() = first * 100 + second \ No newline at end of file
+ get() = first * 100 + second