Skip to content

Commit

Permalink
Merge pull request #36 from kbiakov/develop
Browse files Browse the repository at this point in the history
Fixed escaping html tags before highlighting
  • Loading branch information
kbiakov committed Sep 9, 2017
2 parents abc089b + 4594d3b commit e7de786
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -29,7 +29,7 @@ import java.util.*
abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter.ViewHolder> {

protected val context: Context
protected var lines: List<String> = ArrayList() // items
protected var lines: List<String> = ArrayList()
protected var droppedLines: List<String>? = null

internal var options: Options
Expand Down Expand Up @@ -157,6 +157,7 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
*/
private fun updateContent(code: String, onUpdated: () -> Unit) {
options.code = code
options.isHighlighted = true
prepareCodeLines()
ui(onUpdated)
}
Expand Down Expand Up @@ -227,7 +228,7 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
}
}
tvLineContent.apply {
text = html(lines[pos])
text = lines[pos].let { if (options.isHighlighted) html(it) else it }
textSize = fontSize
setTextColor(options.theme.noteColor.color())
}
Expand Down Expand Up @@ -333,6 +334,8 @@ data class Options(
var maxLines: Int = 0,
var lineClickListener: OnCodeLineClickListener? = null) {

internal var isHighlighted: Boolean = false

fun withCode(code: String): Options {
this.code = code
return this
Expand Down

0 comments on commit e7de786

Please sign in to comment.