Skip to content

Commit 2bc3ac0

Browse files
author
e16din
committed
Fix wrong colorTheme issue.
1 parent 1d06557 commit 2bc3ac0

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,18 @@ class CodeView : RelativeLayout {
172172
// default color theme provided by enum
173173
fun colorTheme(colorTheme: ColorTheme): CodeView {
174174
this.colorTheme = colorTheme.with()
175+
if (rvCodeContent.adapter != null) {
176+
adapter?.colorTheme = this.colorTheme
177+
}
175178
return this
176179
}
177180

178181
// custom color theme provided by user
179182
fun colorTheme(colorTheme: ColorThemeData): CodeView {
180183
this.colorTheme = colorTheme
184+
if (rvCodeContent.adapter != null) {
185+
adapter?.colorTheme = this.colorTheme
186+
}
181187
return this
182188
}
183189

@@ -210,7 +216,7 @@ class CodeView : RelativeLayout {
210216
* @param listener Code line click listener
211217
*/
212218
fun codeListener(listener: OnCodeLineClickListener): CodeView {
213-
if (adapter == null) {
219+
if (adapter == null) {//todo: move code listener to CodeView like codeTheme
214220
throw IllegalStateException("Please set adapter or use codeContent() before highlight()")
215221
}
216222

@@ -221,24 +227,27 @@ class CodeView : RelativeLayout {
221227
/**
222228
* Remove code listener.
223229
*/
224-
fun removeCodeListener() = addTask {
225-
if (adapter == null) {
230+
fun removeCodeListener(): CodeView {
231+
if (adapter == null) {//todo: move code listener to CodeView like codeTheme
226232
throw IllegalStateException("Please set adapter or use codeContent() before highlight()")
227233
}
228234

229235
adapter?.codeListener = null
236+
return this
230237
}
231238

232239
/**
233240
* Control shadows visibility to provide more sensitive UI.
234241
*
235242
* @param isVisible Shadows visibility
236243
*/
237-
fun setShadowsVisible(isVisible: Boolean = true) = addTask {
244+
fun setShadowsVisible(isVisible: Boolean = true): CodeView {
238245
val visibility = if (isVisible) VISIBLE else GONE
239246
vShadowRight.visibility = visibility
240247
vShadowBottomLine.visibility = visibility
241248
vShadowBottomContent.visibility = visibility
249+
250+
return this
242251
}
243252

244253
/**

codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
3333
private val mMaxLines: Int
3434
private var mDroppedLines: List<String>?
3535

36-
protected var colorTheme: ColorThemeData
36+
internal var colorTheme: ColorThemeData
3737

3838
internal var isFullShowing: Boolean
3939

0 commit comments

Comments
 (0)