@@ -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 /* *
0 commit comments