mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-29 20:41:01 +00:00
feat: socials in media
This commit is contained in:
@@ -7,6 +7,7 @@ import ani.dantotsu.connections.anilist.api.MediaList
|
||||
import ani.dantotsu.connections.anilist.api.MediaType
|
||||
import ani.dantotsu.media.anime.Anime
|
||||
import ani.dantotsu.media.manga.Manga
|
||||
import ani.dantotsu.profile.User
|
||||
import java.io.Serializable
|
||||
import ani.dantotsu.connections.anilist.api.Media as ApiMedia
|
||||
|
||||
@@ -66,7 +67,7 @@ data class Media(
|
||||
var sequel: Media? = null,
|
||||
var relations: ArrayList<Media>? = null,
|
||||
var recommendations: ArrayList<Media>? = null,
|
||||
|
||||
var users: ArrayList<User>? = null,
|
||||
var vrvId: String? = null,
|
||||
var crunchySlug: String? = null,
|
||||
|
||||
|
||||
@@ -570,6 +570,23 @@ class MediaInfoFragment : Fragment() {
|
||||
parent.addView(root)
|
||||
}
|
||||
}
|
||||
if(!media.users.isNullOrEmpty() && !offline){
|
||||
ItemTitleRecyclerBinding.inflate(
|
||||
LayoutInflater.from(context),
|
||||
parent,
|
||||
false
|
||||
).apply {
|
||||
itemTitle.setText(R.string.social)
|
||||
itemRecycler.adapter =
|
||||
MediaSocialAdapter(media.users!!)
|
||||
itemRecycler.layoutManager = LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
parent.addView(root)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
49
app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt
Normal file
49
app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
package ani.dantotsu.media
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.databinding.ItemFollowerGridBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.setAnimation
|
||||
|
||||
class MediaSocialAdapter(private val user: ArrayList<User>) :
|
||||
RecyclerView.Adapter<MediaSocialAdapter.DeveloperViewHolder>() {
|
||||
|
||||
inner class DeveloperViewHolder(val binding: ItemFollowerGridBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeveloperViewHolder {
|
||||
return DeveloperViewHolder(
|
||||
ItemFollowerGridBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: DeveloperViewHolder, position: Int) {
|
||||
val b = holder.binding
|
||||
setAnimation(b.root.context, b.root)
|
||||
val user = user[position]
|
||||
b.profileUserName.text = user.name
|
||||
b.profileUserAvatar.loadImage(user.pfp)
|
||||
b.profileInfo.text = user.info
|
||||
b.profileInfo.visibility = View.VISIBLE
|
||||
b.profileUserAvatar.setOnClickListener {
|
||||
val intent = Intent(b.root.context, ProfileActivity::class.java)
|
||||
intent.putExtra("userId", user.id)
|
||||
ContextCompat.startActivity(b.root.context, intent, null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = user.size
|
||||
}
|
||||
Reference in New Issue
Block a user