mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #3658 from Bnyro/master
Fix opening replies by clicking comment
This commit is contained in:
commit
de0dd51db9
@ -1,10 +1,10 @@
|
||||
package com.github.libretube.ui.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
@ -41,6 +41,7 @@ class CommentsAdapter(
|
||||
private val handleLink: ((url: String) -> Unit)?,
|
||||
private val dismiss: () -> Unit
|
||||
) : RecyclerView.Adapter<CommentsViewHolder>() {
|
||||
|
||||
fun clear() {
|
||||
val size: Int = comments.size
|
||||
comments.clear()
|
||||
@ -59,6 +60,17 @@ class CommentsAdapter(
|
||||
return CommentsViewHolder(binding)
|
||||
}
|
||||
|
||||
private fun navigateToReplies(comment: Comment) {
|
||||
val args = bundleOf(
|
||||
IntentData.videoId to videoId,
|
||||
IntentData.comment to JsonHelper.json.encodeToString(comment)
|
||||
)
|
||||
fragment!!.parentFragmentManager.commit {
|
||||
replace<CommentsRepliesFragment>(R.id.commentFragContainer, args = args)
|
||||
addToBackStack(null)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
||||
val comment = comments[position]
|
||||
@ -69,6 +81,10 @@ class CommentsAdapter(
|
||||
commentText.text = comment.commentText
|
||||
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
|
||||
|
||||
commentText.setOnClickListener {
|
||||
navigateToReplies(comment)
|
||||
}
|
||||
|
||||
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
||||
likesTextView.text = comment.likeCount.formatShort()
|
||||
|
||||
@ -105,14 +121,7 @@ class CommentsAdapter(
|
||||
|
||||
if (!isRepliesAdapter && comment.repliesPage != null) {
|
||||
root.setOnClickListener {
|
||||
val args = bundleOf(
|
||||
IntentData.videoId to videoId,
|
||||
IntentData.comment to JsonHelper.json.encodeToString(comment)
|
||||
)
|
||||
fragment!!.parentFragmentManager.commit {
|
||||
replace<CommentsRepliesFragment>(R.id.commentFragContainer, args = args)
|
||||
addToBackStack(null)
|
||||
}
|
||||
navigateToReplies(comment)
|
||||
}
|
||||
}
|
||||
root.setOnLongClickListener {
|
||||
|
Loading…
Reference in New Issue
Block a user