feat(social): continue from where you left
This commit is contained in:
parent
73ef5f4bbc
commit
133354a22d
8 changed files with 70 additions and 38 deletions
|
@ -0,0 +1,72 @@
|
|||
package ani.dantotsu.home.status
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.ItemUserStatusBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.setAnimation
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
|
||||
class UserStatusAdapter(private val user: ArrayList<User>) :
|
||||
RecyclerView.Adapter<UserStatusAdapter.UsersViewHolder>() {
|
||||
|
||||
inner class UsersViewHolder(val binding: ItemUserStatusBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
StatusActivity.user = user
|
||||
ContextCompat.startActivity(
|
||||
itemView.context,
|
||||
Intent(
|
||||
itemView.context,
|
||||
StatusActivity::class.java
|
||||
).putExtra("position", bindingAdapterPosition),
|
||||
null
|
||||
)
|
||||
}
|
||||
itemView.setOnLongClickListener {
|
||||
ContextCompat.startActivity(
|
||||
itemView.context,
|
||||
Intent(
|
||||
itemView.context,
|
||||
ProfileActivity::class.java
|
||||
).putExtra("userId", user[bindingAdapterPosition].id),
|
||||
null
|
||||
)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UsersViewHolder {
|
||||
return UsersViewHolder(
|
||||
ItemUserStatusBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: UsersViewHolder, position: Int) {
|
||||
val b = holder.binding
|
||||
setAnimation(b.root.context, b.root)
|
||||
val user = user[position]
|
||||
b.profileUserAvatar.loadImage(user.pfp)
|
||||
b.profileUserName.text = if (Anilist.userid == user.id) "You" else user.name
|
||||
|
||||
val watchedActivity =
|
||||
PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
||||
val booleanList = user.activity.map { watchedActivity.contains(it.id) }
|
||||
b.profileUserStatusIndicator.setParts(user.activity.size, booleanList, user.id == Anilist.userid)
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = user.size
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue