mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40: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
|
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.LayoutInflater
|
import android.view.*
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.ViewGroup.MarginLayoutParams
|
import android.view.ViewGroup.MarginLayoutParams
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
@ -41,6 +41,7 @@ class CommentsAdapter(
|
|||||||
private val handleLink: ((url: String) -> Unit)?,
|
private val handleLink: ((url: String) -> Unit)?,
|
||||||
private val dismiss: () -> Unit
|
private val dismiss: () -> Unit
|
||||||
) : RecyclerView.Adapter<CommentsViewHolder>() {
|
) : RecyclerView.Adapter<CommentsViewHolder>() {
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
val size: Int = comments.size
|
val size: Int = comments.size
|
||||||
comments.clear()
|
comments.clear()
|
||||||
@ -59,6 +60,17 @@ class CommentsAdapter(
|
|||||||
return CommentsViewHolder(binding)
|
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")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
||||||
val comment = comments[position]
|
val comment = comments[position]
|
||||||
@ -69,6 +81,10 @@ class CommentsAdapter(
|
|||||||
commentText.text = comment.commentText
|
commentText.text = comment.commentText
|
||||||
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
|
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
|
||||||
|
|
||||||
|
commentText.setOnClickListener {
|
||||||
|
navigateToReplies(comment)
|
||||||
|
}
|
||||||
|
|
||||||
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
||||||
likesTextView.text = comment.likeCount.formatShort()
|
likesTextView.text = comment.likeCount.formatShort()
|
||||||
|
|
||||||
@ -105,14 +121,7 @@ class CommentsAdapter(
|
|||||||
|
|
||||||
if (!isRepliesAdapter && comment.repliesPage != null) {
|
if (!isRepliesAdapter && comment.repliesPage != null) {
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
val args = bundleOf(
|
navigateToReplies(comment)
|
||||||
IntentData.videoId to videoId,
|
|
||||||
IntentData.comment to JsonHelper.json.encodeToString(comment)
|
|
||||||
)
|
|
||||||
fragment!!.parentFragmentManager.commit {
|
|
||||||
replace<CommentsRepliesFragment>(R.id.commentFragContainer, args = args)
|
|
||||||
addToBackStack(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
|
Loading…
Reference in New Issue
Block a user