1+ package com.omega_r.libs.omegaintentbuilder.builders
2+
3+ import android.content.Context
4+ import android.content.Intent
5+ import android.provider.AlarmClock.*
6+
7+ class TimerIntentBuilder : BaseActivityBuilder () {
8+ private var message: String? = null
9+ private var seconds: Int? = null
10+ private var skipUI: Boolean? = null
11+
12+ /* *
13+ * Set custom message for the timer.
14+ * <p>
15+ * The value is a {@link String}.
16+ * </p>
17+ *
18+ * @param message String
19+ * @return This TimerIntentBuilder for method chaining
20+ */
21+ fun message (message : String ): TimerIntentBuilder {
22+ this .message = message
23+ return this
24+ }
25+
26+ /* *
27+ * Set the length of the timer in seconds.
28+ *
29+ * @param seconds String
30+ * @return This TimerIntentBuilder for method chaining
31+ */
32+ fun seconds (seconds : Int ): TimerIntentBuilder {
33+ this .seconds = seconds
34+ return this
35+ }
36+
37+ /* *
38+ * Bundle extra: Whether or not to display an activity after performing the action.
39+ * If true, the application is asked to bypass any intermediate UI. If false, the application
40+ * may display intermediate UI like a confirmation dialog or settings.
41+ *
42+ * @param skipUI Boolean
43+ * @return This TimerIntentBuilder for method chaining
44+ */
45+ fun skipUI (skipUI : Boolean ): TimerIntentBuilder {
46+ this .skipUI = skipUI
47+ return this
48+ }
49+
50+ override fun createIntent (context : Context ): Intent {
51+ return Intent (ACTION_SET_TIMER ).apply {
52+ message?.let {
53+ putExtra(EXTRA_MESSAGE , it)
54+ }
55+
56+ seconds?.let {
57+ putExtra(EXTRA_LENGTH , it)
58+ }
59+
60+ skipUI?.let {
61+ putExtra(EXTRA_SKIP_UI , it)
62+ }
63+
64+ }
65+ }
66+
67+ }
0 commit comments