aboutsummaryrefslogtreecommitdiff
path: root/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt
diff options
context:
space:
mode:
Diffstat (limited to 'kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt')
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt29
1 files changed, 21 insertions, 8 deletions
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