indicate when replies are available

This commit is contained in:
Bnyro 2022-10-06 14:35:42 +02:00
parent 1018fd80fb
commit 5c4a23aa33
3 changed files with 40 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package com.github.libretube.ui.adapters package com.github.libretube.ui.adapters
import android.annotation.SuppressLint
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -43,17 +44,16 @@ class CommentsAdapter(
return CommentsViewHolder(binding) return CommentsViewHolder(binding)
} }
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) { override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
val comment = comments[position] val comment = comments[position]
holder.binding.apply { holder.binding.apply {
commentInfos.text = commentInfos.text = comment.author.toString() + "" + comment.commentedTime.toString()
comment.author.toString() + commentText.text = comment.commentText.toString()
"" + comment.commentedTime.toString()
commentText.text =
comment.commentText.toString()
ImageHelper.loadImage(comment.thumbnail, commentorImage) ImageHelper.loadImage(comment.thumbnail, commentorImage)
likesTextView.text = likesTextView.text = comment.likeCount?.toLong().formatShort()
comment.likeCount?.toLong().formatShort()
if (comment.verified == true) { if (comment.verified == true) {
verifiedImageView.visibility = View.VISIBLE verifiedImageView.visibility = View.VISIBLE
} }
@ -63,23 +63,29 @@ class CommentsAdapter(
if (comment.hearted == true) { if (comment.hearted == true) {
heartedImageView.visibility = View.VISIBLE heartedImageView.visibility = View.VISIBLE
} }
if (comment.repliesPage != null) {
commentsAvailable.visibility = View.VISIBLE
}
commentorImage.setOnClickListener { commentorImage.setOnClickListener {
NavigationHelper.navigateChannel(root.context, comment.commentorUrl) NavigationHelper.navigateChannel(root.context, comment.commentorUrl)
} }
repliesRecView.layoutManager = LinearLayoutManager(root.context) repliesRecView.layoutManager = LinearLayoutManager(root.context)
val repliesAdapter = RepliesAdapter(CommentsPage().comments) val repliesAdapter = RepliesAdapter(CommentsPage().comments)
repliesRecView.adapter = repliesAdapter repliesRecView.adapter = repliesAdapter
root.setOnClickListener { root.setOnClickListener {
if (repliesAdapter.itemCount == 0) { when {
if (comment.repliesPage != null) { repliesAdapter.itemCount.equals(0) && comment.repliesPage != null -> {
nextpage = comment.repliesPage nextpage = comment.repliesPage
fetchReplies(nextpage, repliesAdapter) fetchReplies(nextpage, repliesAdapter)
} else { }
repliesAdapter.itemCount.equals(0) -> {
Toast.makeText(root.context, R.string.no_replies, Toast.LENGTH_SHORT) Toast.makeText(root.context, R.string.no_replies, Toast.LENGTH_SHORT)
.show() .show()
} }
} else { else -> repliesAdapter.clear()
repliesAdapter.clear()
} }
} }
} }

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#FF000000"
android:pathData="M12.4,27.5h24v-3h-24ZM12.4,21h24v-3h-24ZM12.4,14.5h24v-3h-24ZM44,44l-8,-8L7,36q-1.15,0 -2.075,-0.925Q4,34.15 4,33L4,7q0,-1.15 0.925,-2.075Q5.85,4 7,4h34q1.2,0 2.1,0.925Q44,5.85 44,7Z" />
</vector>

View File

@ -104,8 +104,20 @@
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
android:visibility="gone" android:visibility="gone"
app:srcCompat="@drawable/ic_hearted" /> app:srcCompat="@drawable/ic_hearted" />
<ImageView
android:id="@+id/comments_available"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_marginStart="8dp"
android:layout_marginTop="3dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_comment" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView