From 1ceb679a88a048017cdd40858708e09461ebb789 Mon Sep 17 00:00:00 2001 From: Ivanov Konstantin Date: Sat, 6 Apr 2019 11:07:39 +0300 Subject: [PATCH] editor adapter hypertext click fix --- .../feature_editor/ui/EditorAdapter.kt | 21 +++++++++---------- .../main/res/layout/item_number_list_item.xml | 3 +-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/feature_editor/src/main/java/com/agileburo/anytype/feature_editor/ui/EditorAdapter.kt b/feature_editor/src/main/java/com/agileburo/anytype/feature_editor/ui/EditorAdapter.kt index 270595091f..08022c6c05 100644 --- a/feature_editor/src/main/java/com/agileburo/anytype/feature_editor/ui/EditorAdapter.kt +++ b/feature_editor/src/main/java/com/agileburo/anytype/feature_editor/ui/EditorAdapter.kt @@ -249,9 +249,11 @@ class EditorAdapter( class BulletHolder(itemView: View) : ViewHolder(itemView) { fun bind(block: BlockView, clickListener: (BlockView) -> Unit) = with(block) { - itemView.tvContent.text = SpannableString(content.text).withBulletSpan(gapWidth = 40, start = 0) + itemView.tvContent.text = + SpannableString(content.text).withBulletSpan(gapWidth = 40, start = 0) .addMarks(marks = content.marks, textView = itemView.tvContent, - click = {}) + click = {Timber.d("Hey Hey I got bullet click : $it")}, itemView = itemView + ) itemView.setOnClickListener { clickListener(this) } } } @@ -262,8 +264,9 @@ class EditorAdapter( itemView.positionText.text = "${param.number}." if (marks.isNotEmpty()) { itemView.contentText.text = SpannableString(text) - .addMarks(marks = marks, textView = itemView.positionText, - click = {}) + .addMarks(marks = marks, textView = itemView.contentText, + click = {Timber.d("Hey Hey I got numbered click : $it") }, itemView = itemView + ) } else { itemView.contentText.text = text } @@ -277,16 +280,12 @@ class EditorAdapter( .addMarks( marks = marks, textView = tvContent, - click = { Timber.d("Hey Hey I got click : $it") }) + click = { Timber.d("Hey Hey I got click : $it") }, + itemView = itemView + ) } else { tvContent.text = content } - - fun getBulletContentSpannable(text: CharSequence, gapWidth: Int, start: Int) = - SpannableString(text).withBulletSpan(gapWidth, start) - .apply { - setSpan(BulletSpan(gapWidth), start, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - } } companion object { diff --git a/feature_editor/src/main/res/layout/item_number_list_item.xml b/feature_editor/src/main/res/layout/item_number_list_item.xml index a7351bbe73..1dc6c8e3d1 100644 --- a/feature_editor/src/main/res/layout/item_number_list_item.xml +++ b/feature_editor/src/main/res/layout/item_number_list_item.xml @@ -1,8 +1,7 @@