md支持图片

pull/457/head
gedoor 4 years ago
parent dfe1fb54ff
commit 5a6928407c
  1. 3
      app/build.gradle
  2. 9
      app/src/main/assets/help/help.md
  3. 12
      app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt

@ -197,7 +197,8 @@ dependencies {
implementation 'net.ricecode:string-similarity:1.0.0' implementation 'net.ricecode:string-similarity:1.0.0'
//MarkDown //MarkDown
implementation 'ru.noties.markwon:core:3.1.0' implementation 'io.noties.markwon:core:4.6.0'
implementation 'io.noties.markwon:image-glide:4.6.0'
// //
implementation 'com.hankcs:hanlp:portable-1.7.8' implementation 'com.hankcs:hanlp:portable-1.7.8'

File diff suppressed because one or more lines are too long

@ -8,10 +8,11 @@ import android.view.ViewGroup
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.noties.markwon.Markwon
import io.noties.markwon.image.glide.GlideImagesPlugin
import kotlinx.android.synthetic.main.dialog_text_view.* import kotlinx.android.synthetic.main.dialog_text_view.*
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import ru.noties.markwon.Markwon
class TextDialog : BaseDialogFragment() { class TextDialog : BaseDialogFragment() {
@ -63,11 +64,10 @@ class TextDialog : BaseDialogFragment() {
val content = it.getString("content") ?: "" val content = it.getString("content") ?: ""
when (it.getInt("mode")) { when (it.getInt("mode")) {
MD -> text_view.post { MD -> text_view.post {
Markwon.create(requireContext()) Markwon.builder(requireContext())
.setMarkdown( .usePlugin(GlideImagesPlugin.create(requireContext()))
text_view, .build()
content .setMarkdown(text_view, content)
)
} }
else -> text_view.text = content else -> text_view.text = content
} }

Loading…
Cancel
Save