Improvement of links in description and comment texts.

This commit is contained in:
Faisal Khan 2023-04-28 16:14:39 +05:30
parent de0dd51db9
commit 1a2d8ddd0b
2 changed files with 6 additions and 8 deletions

View File

@ -1,8 +1,6 @@
package com.github.libretube.ui.adapters package com.github.libretube.ui.adapters
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Handler
import android.os.Looper
import android.text.method.LinkMovementMethod import android.text.method.LinkMovementMethod
import android.view.* import android.view.*
import android.view.ViewGroup.MarginLayoutParams import android.view.ViewGroup.MarginLayoutParams
@ -78,7 +76,7 @@ class CommentsAdapter(
commentInfos.text = comment.author + TextUtils.SEPARATOR + comment.commentedTime commentInfos.text = comment.author + TextUtils.SEPARATOR + comment.commentedTime
commentText.movementMethod = LinkMovementMethod.getInstance() commentText.movementMethod = LinkMovementMethod.getInstance()
commentText.text = comment.commentText commentText.text = comment.commentText?.replace("</a>", "</a> ")
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {}))) ?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
commentText.setOnClickListener { commentText.setOnClickListener {

View File

@ -110,10 +110,6 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.upstream.DefaultDataSource import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.util.MimeTypes import com.google.android.exoplayer2.util.MimeTypes
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -122,6 +118,10 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.decodeFromString import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
class PlayerFragment : Fragment(), OnlinePlayerOptions { class PlayerFragment : Fragment(), OnlinePlayerOptions {
private var _binding: FragmentPlayerBinding? = null private var _binding: FragmentPlayerBinding? = null
@ -1087,7 +1087,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
// detect whether the description is html formatted // detect whether the description is html formatted
if (description.contains("<") && description.contains(">")) { if (description.contains("<") && description.contains(">")) {
descTextView.movementMethod = LinkMovementMethod.getInstance() descTextView.movementMethod = LinkMovementMethod.getInstance()
descTextView.text = description descTextView.text = description.replace("</a>", "</a> ")
.parseAsHtml(tagHandler = HtmlParser(LinkHandler(this::handleLink))) .parseAsHtml(tagHandler = HtmlParser(LinkHandler(this::handleLink)))
} else { } else {
// Links can be present as plain text // Links can be present as plain text