/
HighlightParameter.kt
158 lines (127 loc) · 4.65 KB
/
HighlightParameter.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.hyy.highlightpro.parameter
import android.graphics.RectF
import android.view.View
import android.view.animation.Animation
import com.hyy.highlightpro.shape.HighlightShape
/**
* Create by hyy on 2021/2/6
*
* [HighlightParameter] is a build mode for user to set
* parameters to build the [GuideView]
*/
class HighlightParameter {
internal var highLightViewId: Int = -1
internal var highLightView: View? = null
internal var tipsViewId: Int = -1
internal var tipsView: View? = null
internal var highlightShape: HighlightShape? = null
internal var rect: RectF = RectF()
internal var horizontalPadding: Float = 0f
internal var verticalPadding: Float = 0f
internal var marginOffset: MarginOffset = MarginOffset()
internal var offsetX = 0
internal var offsetY = 0
internal val constraints =
mutableListOf(Constraints.TopToBottomOfHighlight, Constraints.StartToStartOfHighlight)
internal var tipViewDisplayAnimation: Animation? = null
fun setHighLightViewId(viewId: Int) {
this.highLightViewId = viewId
}
fun setHighLightView(highLightView: View) {
this.highLightView = highLightView
}
operator fun plus(highlightParameter: HighlightParameter): List<HighlightParameter> {
return listOf(this, highlightParameter)
}
class Builder {
private val highlightParameter: HighlightParameter = HighlightParameter()
/**
* [viewId] is the highLightView's id
* it will be override by [setHighlightView].
*/
fun setHighlightViewId(viewId: Int): Builder {
highlightParameter.highLightViewId = viewId
return this
}
/**
* [highLightView] is the view which you want to make it highLight
* And it will make [setHighlightViewId] useless.
*/
fun setHighlightView(highLightView: View): Builder {
highlightParameter.highLightView = highLightView
return this
}
/**
* [viewId] is the tipsView's id
* it will be override by [setTipsView].
*/
fun setTipsViewId(viewId: Int): Builder {
highlightParameter.tipsViewId = viewId
return this
}
/**
* [tipsView] is the view which you want to add it on [GuideViewContainer]
* And it will make [setTipsViewId] useless.
*/
fun setTipsView(tipsView: View): Builder {
highlightParameter.tipsView = tipsView
return this
}
/**
* [highlightShape] is the highlight out rect shape and you can
* custom your shape reference our shapes exit.
*/
fun setHighlightShape(highlightShape: HighlightShape): Builder {
highlightParameter.highlightShape = highlightShape
return this
}
/**
* [padding] is the vertical dimension padding use by expand the rect area of
* highlight.
*/
fun setHighlightVerticalPadding(padding: Float): Builder {
highlightParameter.verticalPadding = padding
return this
}
/**
* [marginOffset] is the extra dimension use by position highlight rect.
*/
fun setMarginOffset(marginOffset: MarginOffset): Builder {
highlightParameter.marginOffset = marginOffset
return this
}
/**
* [constraints] is a list of constraints provides some constraints of highlight
* rect position.
*/
fun setConstraints(constraints: List<Constraints>): Builder {
highlightParameter.constraints.clear()
highlightParameter.constraints.addAll(constraints)
return this
}
/**
* [padding] is the horizontal dimension padding use by expand the rect area of
* highlight.
*/
fun setHighlightHorizontalPadding(padding: Float): Builder {
highlightParameter.horizontalPadding = padding
return this
}
/**
* [tipViewDisplayAnimation] is the animation to display for Highlight tips view
*/
fun setTipViewDisplayAnimation(tipViewDisplayAnimation: Animation?): Builder {
highlightParameter.tipViewDisplayAnimation = tipViewDisplayAnimation
return this
}
fun offsetX(offsetX: Int): Builder {
highlightParameter.offsetX = offsetX
return this
}
fun offsetY(offsetY: Int): Builder {
highlightParameter.offsetY = offsetY
return this
}
fun build(): HighlightParameter = highlightParameter
}
}