11package com.ackee.versioupdatehandler.model
22
3- import android.os.Parcel
43import android.os.Parcelable
4+ import kotlinx.android.parcel.Parcelize
55
66/* *
77 * Visual settings of dialog
88 */
9- class DialogSettings : Parcelable {
10-
11- var packageName: String?
12- var title: String?
13- var titleRes: Int
14- var message: String?
15- var messageRes: Int
16- var positiveButton: String?
17- var positiveButtonRes: Int
18- var negativeButton: String?
19- var negativeButtonRes: Int
20-
21- private constructor (builder: Builder ) {
22- packageName = builder.packageName
23- title = builder.title
24- titleRes = builder.titleRes
25- message = builder.message
26- messageRes = builder.messageRes
27- negativeButton = builder.negativeButton
28- positiveButton = builder.positiveButton
29- positiveButtonRes = builder.positiveButtonRes
30- negativeButtonRes = builder.negativeButtonRes
31- }
32-
33- protected constructor (parcelableValue: Parcel ) {
34- packageName = parcelableValue.readString()
35- title = parcelableValue.readString()
36- message = parcelableValue.readString()
37- positiveButton = parcelableValue.readString()
38- negativeButton = parcelableValue.readString()
39- messageRes = parcelableValue.readInt()
40- titleRes = parcelableValue.readInt()
41- positiveButtonRes = parcelableValue.readInt()
42- negativeButtonRes = parcelableValue.readInt()
43- }
44-
45- override fun describeContents (): Int {
46- return 0
47- }
48-
49- override fun writeToParcel (dest : Parcel , flags : Int ) {
50- dest.writeString(packageName)
51- dest.writeString(title)
52- dest.writeString(message)
53- dest.writeString(positiveButton)
54- dest.writeString(negativeButton)
55- dest.writeInt(messageRes)
56- dest.writeInt(titleRes)
57- dest.writeInt(positiveButtonRes)
58- dest.writeInt(negativeButtonRes)
59- }
60-
61- class Builder {
62- internal var messageRes: Int
63- internal var message: String?
64- internal var titleRes: Int
65- internal var title: String?
66- internal var packageName: String?
67- internal var positiveButton: String?
68- internal var positiveButtonRes: Int
69- internal var negativeButton: String?
70- internal var negativeButtonRes: Int
71-
72- init {
73- messageRes = - 1
74- message = null
75- titleRes = - 1
76- title = null
77- packageName = null
78- positiveButton = null
79- positiveButtonRes = - 1
80- negativeButton = null
81- negativeButtonRes = - 1
82- }
83-
84- fun messageRes (value : Int ): Builder {
85- messageRes = value
86- return this
87- }
88-
89- fun message (value : String? ): Builder {
90- message = value
91- return this
92- }
93-
94- fun titleRes (value : Int ): Builder {
95- titleRes = value
96- return this
97- }
98-
99- fun title (value : String? ): Builder {
100- title = value
101- return this
102- }
103-
104- fun packageName (value : String? ): Builder {
105- packageName = value
106- return this
107- }
108-
109- fun positiveButtonRes (value : Int ): Builder {
110- positiveButtonRes = value
111- return this
112- }
113-
114- fun positiveButton (value : String? ): Builder {
115- positiveButton = value
116- return this
117- }
118-
119- fun negativeButtonRes (value : Int ): Builder {
120- negativeButtonRes = value
121- return this
122- }
123-
124- fun negativeButton (value : String? ): Builder {
125- negativeButton = value
126- return this
127- }
128-
129- fun build (): DialogSettings {
130- return DialogSettings (this )
131- }
132- }
133- }
9+ @Parcelize
10+ class DialogSettings (
11+ val packageName : String? ,
12+ val title : String? ,
13+ val titleRes : Int ,
14+ val message : String? ,
15+ val messageRes : Int ,
16+ val positiveButton : String? ,
17+ val positiveButtonRes : Int ,
18+ val negativeButton : String? ,
19+ val negativeButtonRes : Int
20+ ) : Parcelable
0 commit comments