I initially have this code when using this old library, the idea here is to support the scenario where multiple table tags exist in data then render multiple table span in TextView. To get onclick events it is using the newInstance()
method.
htmlTxtV.setClickableTableSpan(ClickableTableSpanImpl(intentDomain))
inner class ClickableTableSpanImpl(private val intentDomain: WordPressPostDataDomain) :
ClickableTableSpan() {
override fun newInstance(): ClickableTableSpan {
return ClickableTableSpanImpl(intentDomain)
}
override fun onClick(widget: View) {
// Do task here
}
}
If I convert it to anonymous object
setClickableTableSpan(object : ClickableTableSpan() {
override fun newInstance(): ClickableTableSpan {
return this
}
override fun onClick(widget: View) {
// Do task here
}
})
I only get single callback from the last span. Meaning the return this
is not equivalent to return ClickableTableSpanImpl()
. Is it possible to create new instance by just using anonymous object?