@@ -59,19 +59,19 @@ fun AztecText.hasImageCaption(attributePredicate: AztecText.AttributePredicate):
5959}
6060
6161fun AztecImageSpan.getCaption (): String {
62- textView?.text?.let {
63- val wrapper = SpanWrapper (textView !! .text , this )
64- textView !! .text .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.let {
62+ textView?.get()?. text?.let { editable ->
63+ val wrapper = SpanWrapper (editable , this )
64+ editable .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.let {
6565 return it.caption
6666 }
6767 }
6868 return " "
6969}
7070
7171fun AztecImageSpan.getCaptionAttributes (): AztecAttributes {
72- textView?.text?.let {
73- val wrapper = SpanWrapper (textView !! .text , this )
74- textView !! .text .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.let {
72+ textView?.get()?. text?.let { editable ->
73+ val wrapper = SpanWrapper (editable , this )
74+ editable .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.let {
7575 return it.attributes
7676 }
7777 }
@@ -80,17 +80,17 @@ fun AztecImageSpan.getCaptionAttributes(): AztecAttributes {
8080
8181@JvmOverloads
8282fun AztecImageSpan.setCaption (value : String , attrs : AztecAttributes ? = null) {
83- textView?.text?.let {
84- val wrapper = SpanWrapper (textView !! .text , this )
83+ textView?.get()?. text?.let { editable ->
84+ val wrapper = SpanWrapper (editable , this )
8585
86- var captionSpan = textView?.text? .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java)?.firstOrNull()
86+ var captionSpan = editable .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java)?.firstOrNull()
8787 if (captionSpan == null ) {
8888 captionSpan = createCaptionShortcodeSpan(
8989 AztecAttributes (),
9090 CaptionShortcodePlugin .HTML_TAG ,
91- IAztecNestable .getNestingLevelAt(textView !! .text , wrapper.start),
92- textView!! )
93- textView !! .text .setSpan(captionSpan, wrapper.start, wrapper.end, Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
91+ IAztecNestable .getNestingLevelAt(editable , wrapper.start),
92+ textView?.get() !! )
93+ editable .setSpan(captionSpan, wrapper.start, wrapper.end, Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
9494 }
9595
9696 captionSpan.caption = value
@@ -114,8 +114,8 @@ fun AztecImageSpan.setCaption(value: String, attrs: AztecAttributes? = null) {
114114}
115115
116116fun AztecImageSpan.removeCaption () {
117- textView?.text?.let {
118- val wrapper = SpanWrapper (textView !! .text , this )
119- textView !! .text .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.remove()
117+ textView?.get()?. text?.let { editable ->
118+ val wrapper = SpanWrapper (editable , this )
119+ editable .getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan ::class .java).firstOrNull()?.remove()
120120 }
121121}
0 commit comments