Skip to content

Commit 8240c3a

Browse files
authored
Merge pull request #2 from Softwee/develop
Improved adapter initialization, added shadows control
2 parents e9f6e99 + 1ef929d commit 8240c3a

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt

+18-12
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,20 @@ class CodeView : RelativeLayout {
8585
/**
8686
* Public getter for accessing view state.
8787
* 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.
8989
*/
9090
fun getState() = state
9191

9292
/**
93-
* Accessor/mutator to reduce frequently used actions
93+
* Accessor/mutator to reduce frequently used actions.
9494
*/
9595
var adapter: CodeContentAdapter
9696
get() {
9797
return rvCodeContent.adapter as CodeContentAdapter
9898
}
9999
set(adapter) {
100100
rvCodeContent.adapter = adapter
101+
state = ViewState.PRESENTED
101102
}
102103

103104
// - Build processor
@@ -122,7 +123,7 @@ class CodeView : RelativeLayout {
122123
}
123124

124125
/**
125-
* Process build tasks queue to build view
126+
* Process build tasks queue to build view.
126127
*/
127128
private fun processBuildTasks() {
128129
while (tasks.isNotEmpty())
@@ -172,6 +173,16 @@ class CodeView : RelativeLayout {
172173
adapter.codeListener = listener
173174
}
174175

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+
175186
/**
176187
* Update code content if view was built or, finally, build code view.
177188
*/
@@ -205,7 +216,7 @@ class CodeView : RelativeLayout {
205216
Thread.delayed {
206217
rvCodeContent.adapter = CodeContentAdapter(context, content)
207218
processBuildTasks()
208-
setupShortcutShadows()
219+
setupShadows()
209220
hidePlaceholder()
210221
state = ViewState.PRESENTED
211222
}
@@ -214,15 +225,10 @@ class CodeView : RelativeLayout {
214225
// - Setup actions
215226

216227
/**
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.
219230
*/
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)
226232

227233
/**
228234
* Placeholder fills space at start and stretched to marked up view size

codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ data class SyntaxColors(
171171
val attrValue: Int = 0x269186)
172172

173173
/**
174-
* Convert hex int to color by adding alpha-channel
174+
* Convert hex int to color by adding alpha-channel.
175175
*
176176
* @return Color int
177177
*/
@@ -182,7 +182,7 @@ fun Int.color() = try {
182182
}
183183

184184
/**
185-
* Convert hex int to hex string
185+
* Convert hex int to hex string.
186186
*
187187
* @return Hex string
188188
*/

0 commit comments

Comments
 (0)