@@ -85,19 +85,20 @@ class CodeView : RelativeLayout {
85
85
/* *
86
86
* Public getter for accessing view state.
87
87
* It may be useful if code view state is unknown.
88
- * If code view was built rhis is not safe to use operations chaining.
88
+ * If code view was built it is not safe to use operations chaining.
89
89
*/
90
90
fun getState () = state
91
91
92
92
/* *
93
- * Accessor/mutator to reduce frequently used actions
93
+ * Accessor/mutator to reduce frequently used actions.
94
94
*/
95
95
var adapter: CodeContentAdapter
96
96
get() {
97
97
return rvCodeContent.adapter as CodeContentAdapter
98
98
}
99
99
set(adapter) {
100
100
rvCodeContent.adapter = adapter
101
+ state = ViewState .PRESENTED
101
102
}
102
103
103
104
// - Build processor
@@ -122,7 +123,7 @@ class CodeView : RelativeLayout {
122
123
}
123
124
124
125
/* *
125
- * Process build tasks queue to build view
126
+ * Process build tasks queue to build view.
126
127
*/
127
128
private fun processBuildTasks () {
128
129
while (tasks.isNotEmpty())
@@ -172,6 +173,16 @@ class CodeView : RelativeLayout {
172
173
adapter.codeListener = listener
173
174
}
174
175
176
+ /* *
177
+ * Control shadows visibility to provide more sensitive UI.
178
+ */
179
+ fun setShadowsVisible (isVisible : Boolean = true) = addTask {
180
+ val visibility = if (isVisible) View .VISIBLE else GONE
181
+ vShadowRight.visibility = visibility
182
+ vShadowBottomLine.visibility = visibility
183
+ vShadowBottomContent.visibility = visibility
184
+ }
185
+
175
186
/* *
176
187
* Update code content if view was built or, finally, build code view.
177
188
*/
@@ -205,7 +216,7 @@ class CodeView : RelativeLayout {
205
216
Thread .delayed {
206
217
rvCodeContent.adapter = CodeContentAdapter (context, content)
207
218
processBuildTasks()
208
- setupShortcutShadows ()
219
+ setupShadows ()
209
220
hidePlaceholder()
210
221
state = ViewState .PRESENTED
211
222
}
@@ -214,15 +225,10 @@ class CodeView : RelativeLayout {
214
225
// - Setup actions
215
226
216
227
/* *
217
- * Border shadows will shown if presented listing shortcut .
218
- * It helps user to what parts of content are scrolled & hidden.
228
+ * Border shadows will shown if presented full code listing .
229
+ * It helps user to see what part of content are scrolled & hidden.
219
230
*/
220
- private fun setupShortcutShadows () {
221
- val visibility = if (adapter.isFullShowing) GONE else VISIBLE
222
- vShadowRight.visibility = visibility
223
- vShadowBottomLine.visibility = visibility
224
- vShadowBottomContent.visibility = visibility
225
- }
231
+ private fun setupShadows () = setShadowsVisible(! adapter.isFullShowing)
226
232
227
233
/* *
228
234
* Placeholder fills space at start and stretched to marked up view size
0 commit comments