yydcdut / RxMarkdown

:fax:Markdown for Android, supports TextView && EditText (Live Preview), supports code high light.
749 stars 93 forks source link

setOnLinkClickCallback does not appear to be working #61

Open MikeSimpson opened 5 years ago

MikeSimpson commented 5 years ago

Links appear underlined and coloured correctly with the following snippet but the links are not clickable. Using text_view.setMovementMethod(LinkMovementMethod.getInstance()) works correctly but handling links in MarkdownConfiguration.Builder does not.

 MarkdownConfiguration.Builder(context)
                .setLinkFontColor(
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        context.resources.getColor(R.color.colorPrimary, null)
                    } else {
                        context.resources.getColor(R.color.colorPrimary)
                    }
                ).setOnLinkClickCallback { view, link ->
                    Timber.d("Not reached")
                    context.startActivity(Intent(Intent.ACTION_VIEW).apply {
                        data = Uri.parse(link)
                    })
                }.build()
            text_view.text = MarkdownProcessor(context).apply {
                factory(TextFactory.create())
                config(markdownConfig)
            }.parse(content)
nikartx commented 3 years ago

Hi, I fixed this issue using textView.movementMethod = LinkMovementMethod.getInstance()