feat : qol things
This commit is contained in:
parent
039e3d63fe
commit
48ccb2c581
9 changed files with 98 additions and 110 deletions
|
@ -528,26 +528,11 @@ class MediaInfoFragment : Fragment() {
|
|||
parent,
|
||||
false
|
||||
).apply {
|
||||
fun onUserClick(userId: Int) {
|
||||
val review = media.review!!.find { i -> i.id == userId }
|
||||
if (review != null) {
|
||||
startActivity(
|
||||
Intent(requireContext(), ReviewViewActivity::class.java)
|
||||
.putExtra("review", review)
|
||||
)
|
||||
}
|
||||
}
|
||||
val adapter = GroupieAdapter()
|
||||
media.review!!.forEach {
|
||||
adapter.add(ReviewAdapter(it, ::onUserClick))
|
||||
}
|
||||
media.review!!.forEach { adapter.add(ReviewAdapter(it)) }
|
||||
itemTitle.setText(R.string.reviews)
|
||||
itemRecycler.adapter = adapter
|
||||
itemRecycler.layoutManager = LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
itemRecycler.layoutManager = LinearLayoutManager(requireContext())
|
||||
itemMore.visibility = View.VISIBLE
|
||||
itemMore.setSafeOnClickListener {
|
||||
startActivity(
|
||||
|
|
|
@ -122,19 +122,7 @@ class ReviewActivity : AppCompatActivity() {
|
|||
private fun fillList() {
|
||||
adapter.clear()
|
||||
reviews.forEach {
|
||||
adapter.add(
|
||||
ReviewAdapter(
|
||||
it,
|
||||
this::onUserClick
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onUserClick(userId: Int) {
|
||||
val review = reviews.find { it.id == userId }
|
||||
if (review != null) {
|
||||
startActivity(Intent(this, ReviewViewActivity::class.java).putExtra("review", review))
|
||||
adapter.add(ReviewAdapter(it))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,24 @@
|
|||
package ani.dantotsu.media
|
||||
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.util.Pair
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.anilist.api.Query
|
||||
import ani.dantotsu.databinding.ItemReviewsBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.openImage
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||
import ani.dantotsu.toast
|
||||
import com.xwray.groupie.viewbinding.BindableItem
|
||||
|
@ -18,19 +30,49 @@ import kotlinx.coroutines.withContext
|
|||
|
||||
class ReviewAdapter(
|
||||
private var review: Query.Review,
|
||||
val clickCallback: (Int) -> Unit
|
||||
) : BindableItem<ItemReviewsBinding>() {
|
||||
private lateinit var binding: ItemReviewsBinding
|
||||
|
||||
override fun bind(viewBinding: ItemReviewsBinding, position: Int) {
|
||||
binding = viewBinding
|
||||
val context = binding.root.context
|
||||
binding.reviewUserName.text = review.user?.name
|
||||
binding.reviewUserAvatar.loadImage(review.user?.avatar?.medium)
|
||||
binding.reviewText.text = review.summary
|
||||
binding.reviewPostTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
||||
val text = "[${review.score/ 10.0f}]"
|
||||
binding.reviewTag.text = text
|
||||
binding.root.setOnClickListener { clickCallback(review.id) }
|
||||
binding.root.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
context,
|
||||
Intent(context, ReviewViewActivity::class.java)
|
||||
.putExtra("review", review),
|
||||
null
|
||||
)
|
||||
}
|
||||
binding.reviewUserName.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
context,
|
||||
Intent(context, ProfileActivity::class.java)
|
||||
.putExtra("userId", review.user?.id),
|
||||
null
|
||||
)
|
||||
}
|
||||
binding.reviewUserAvatar.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
context,
|
||||
Intent(context, ProfileActivity::class.java)
|
||||
.putExtra("userId", review.user?.id),
|
||||
null
|
||||
)
|
||||
}
|
||||
binding.reviewUserAvatar.openImage(
|
||||
context.getString(
|
||||
R.string.avatar,
|
||||
review.user?.name
|
||||
),
|
||||
review.user?.avatar?.medium ?: ""
|
||||
)
|
||||
userVote(review.userRating)
|
||||
enableVote()
|
||||
binding.reviewTotalVotes.text = review.rating.toString()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ani.dantotsu.media
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -18,6 +19,9 @@ import ani.dantotsu.getThemeColor
|
|||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.openImage
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
@ -47,6 +51,20 @@ class ReviewViewActivity : AppCompatActivity() {
|
|||
binding.userName.text = review.user?.name
|
||||
binding.userAvatar.loadImage(review.user?.avatar?.medium)
|
||||
binding.userTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
||||
binding.userContainer.setOnClickListener {
|
||||
startActivity(Intent(this, ProfileActivity::class.java)
|
||||
.putExtra("userId", review.user?.id)
|
||||
)
|
||||
}
|
||||
binding.userAvatar.openImage(
|
||||
binding.root.context.getString(R.string.avatar, review.user?.name),
|
||||
review.user?.avatar?.medium ?: ""
|
||||
)
|
||||
binding.userAvatar.setOnClickListener {
|
||||
startActivity(Intent(this, ProfileActivity::class.java)
|
||||
.putExtra("userId", review.user?.id)
|
||||
)
|
||||
}
|
||||
binding.profileUserBio.settings.loadWithOverviewMode = true
|
||||
binding.profileUserBio.settings.useWideViewPort = true
|
||||
binding.profileUserBio.setInitialScale(1)
|
||||
|
|
|
@ -14,6 +14,7 @@ import ani.dantotsu.copyToClipboard
|
|||
import ani.dantotsu.databinding.ItemCommentsBinding
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.openImage
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.setAnimation
|
||||
|
@ -251,13 +252,10 @@ class CommentItem(
|
|||
}
|
||||
}
|
||||
commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString()
|
||||
commentUserAvatar.setOnLongClickListener {
|
||||
ImageViewDialog.newInstance(
|
||||
commentsFragment.activity,
|
||||
commentsFragment.activity.getString(R.string.avatar, comment.username),
|
||||
comment.profilePictureUrl
|
||||
)
|
||||
}
|
||||
commentUserAvatar.openImage(
|
||||
commentsFragment.activity.getString(R.string.avatar, comment.username),
|
||||
comment.profilePictureUrl ?: ""
|
||||
)
|
||||
comment.profilePictureUrl?.let { commentUserAvatar.loadImage(it) }
|
||||
commentUserName.text = comment.username
|
||||
val userColor = "[${levelColor.second}]"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue