feat: long tap like button to see users
This commit is contained in:
parent
c5abfa15e0
commit
5dbc01dba3
11 changed files with 186 additions and 41 deletions
|
@ -1354,7 +1354,7 @@ Page(page:$page,perPage:50) {
|
|||
suspend fun getFeed(userId: Int?, global: Boolean = false, page: Int = 1, activityId: Int? = null): FeedResponse? {
|
||||
val filter = if (activityId != null) "id:$activityId,"
|
||||
else if (userId != null) "userId:$userId,"
|
||||
else if (global) "isFollowing:false,type:TEXT,"
|
||||
else if (global) "isFollowing:false,hasReplies:true,"
|
||||
else "isFollowing:true,type_not:MESSAGE,"
|
||||
return executeQuery<FeedResponse>(
|
||||
"""{Page(page:$page,perPage:$ITEMS_PER_PAGE){activities(${filter}sort:ID_DESC){__typename ... on TextActivity{id userId type replyCount text(asHtml:true)siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on ListActivity{id userId type replyCount status progress siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}media{id title{english romaji native userPreferred}bannerImage coverImage{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on MessageActivity{id recipientId messengerId type replyCount likeCount message(asHtml:true)isLocked isSubscribed isLiked isPrivate siteUrl createdAt recipient{id name bannerImage avatar{medium large}}messenger{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}}}}"""
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
package ani.dantotsu.profile
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
|
||||
import android.view.View
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.blurImage
|
||||
import ani.dantotsu.databinding.ItemFollowerBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.model.GlideUrl
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.xwray.groupie.viewbinding.BindableItem
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation
|
||||
|
||||
class FollowerItem(
|
||||
private val id: Int,
|
||||
|
|
|
@ -43,7 +43,7 @@ import kotlin.math.abs
|
|||
|
||||
class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListener {
|
||||
lateinit var binding: ActivityProfileBinding
|
||||
private var selected: Int = 1
|
||||
private var selected: Int = 0
|
||||
private lateinit var navBar: AnimatedBottomBar
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
@ -59,8 +59,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
val feedTab = navBar.createTab(R.drawable.ic_round_filter_24, "Feed")
|
||||
val profileTab = navBar.createTab(R.drawable.ic_round_person_24, "Profile")
|
||||
val statsTab = navBar.createTab(R.drawable.ic_stats_24, "Stats")
|
||||
navBar.addTab(feedTab)
|
||||
navBar.addTab(profileTab)
|
||||
navBar.addTab(feedTab)
|
||||
navBar.addTab(statsTab)
|
||||
navBar.visibility = View.GONE
|
||||
binding.profileViewPager.isUserInputEnabled = false
|
||||
|
@ -117,7 +117,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
}
|
||||
}
|
||||
binding.profileProgressBar.visibility = View.GONE
|
||||
binding.profileTopContainer.visibility = View.VISIBLE
|
||||
binding.profileAppBar.visibility = View.VISIBLE
|
||||
binding.profileMenuButton.setOnClickListener {
|
||||
val popup = PopupMenu(this@ProfileActivity, binding.profileMenuButton)
|
||||
popup.menuInflater.inflate(R.menu.menu_profile, popup.menu)
|
||||
|
@ -240,8 +240,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
|
||||
override fun getItemCount(): Int = 3
|
||||
override fun createFragment(position: Int): Fragment = when (position) {
|
||||
0 -> FeedFragment.newInstance(user.id, false, -1)
|
||||
1 -> ProfileFragment.newInstance(user)
|
||||
0 -> ProfileFragment.newInstance(user)
|
||||
1 -> FeedFragment.newInstance(user.id, false, -1)
|
||||
2 -> StatsFragment.newInstance(user)
|
||||
else -> ProfileFragment.newInstance(user)
|
||||
}
|
||||
|
|
8
app/src/main/java/ani/dantotsu/profile/User.kt
Normal file
8
app/src/main/java/ani/dantotsu/profile/User.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
package ani.dantotsu.profile
|
||||
|
||||
data class User(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val pfp: String?,
|
||||
val banner: String?,
|
||||
)
|
|
@ -0,0 +1,41 @@
|
|||
package ani.dantotsu.profile
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.BottomSheetDialogFragment
|
||||
import ani.dantotsu.databinding.BottomSheetUsersBinding
|
||||
import ani.dantotsu.profile.activity.UsersAdapter
|
||||
import ani.dantotsu.settings.DevelopersAdapter
|
||||
|
||||
|
||||
class UsersDialogFragment : BottomSheetDialogFragment() {
|
||||
private var _binding: BottomSheetUsersBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private var userList = arrayListOf<User>()
|
||||
fun userList(user: ArrayList<User>){
|
||||
userList = user
|
||||
}
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetUsersBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.usersRecyclerView.adapter = UsersAdapter(userList)
|
||||
binding.usersRecyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
_binding = null
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package ani.dantotsu.profile.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.blurImage
|
||||
|
@ -12,6 +12,8 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.connections.anilist.api.Activity
|
||||
import ani.dantotsu.databinding.ItemActivityBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.profile.UsersDialogFragment
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.util.AniMarkdown.Companion.getBasicAniHTML
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -29,7 +31,8 @@ import kotlinx.coroutines.withContext
|
|||
|
||||
class ActivityItem(
|
||||
private val activity: Activity,
|
||||
val clickCallback: (Int, type: String) -> Unit
|
||||
val clickCallback: (Int, type: String) -> Unit,
|
||||
private val FragActivity: FragmentActivity
|
||||
) : BindableItem<ItemActivityBinding>() {
|
||||
private lateinit var binding: ItemActivityBinding
|
||||
private lateinit var repliesAdapter: GroupieAdapter
|
||||
|
@ -102,8 +105,18 @@ class ActivityItem(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val context = binding.root.context
|
||||
val userList = arrayListOf<User>()
|
||||
activity.likes?.forEach{ i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
binding.activityLike.setOnLongClickListener{
|
||||
UsersDialogFragment().apply { userList(userList)
|
||||
show(FragActivity.supportFragmentManager, "dialog")
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
when (activity.typename) {
|
||||
"ListActivity" -> {
|
||||
|
|
|
@ -72,7 +72,7 @@ class FeedFragment : Fragment() {
|
|||
val filtered = activityList.filterNot { //filter out messages that are not directed to the user
|
||||
it.recipient?.id != null && it.recipient.id != Anilist.userid
|
||||
}
|
||||
adapter.update(filtered.map { ActivityItem(it, ::onActivityClick) })
|
||||
adapter.update(filtered.map { ActivityItem(it, ::onActivityClick,requireActivity()) })
|
||||
}
|
||||
binding.listProgressBar.visibility = ViewGroup.GONE
|
||||
val scrollView = binding.listRecyclerView
|
||||
|
@ -95,7 +95,7 @@ class FeedFragment : Fragment() {
|
|||
val filtered = activities.filterNot {
|
||||
it.recipient?.id != null && it.recipient.id != Anilist.userid
|
||||
}
|
||||
adapter.addAll(filtered.map { ActivityItem(it, ::onActivityClick) })
|
||||
adapter.addAll(filtered.map { ActivityItem(it, ::onActivityClick,requireActivity()) })
|
||||
}
|
||||
binding.feedRefresh.visibility = ViewGroup.GONE
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package ani.dantotsu.profile.activity
|
||||
|
||||
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.databinding.ItemFollowerBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.setAnimation
|
||||
|
||||
|
||||
class UsersAdapter(private val user: ArrayList<User>) : RecyclerView.Adapter<UsersAdapter.UsersViewHolder>() {
|
||||
|
||||
inner class UsersViewHolder(val binding: ItemFollowerBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
binding.root.context, Intent(binding.root.context, ProfileActivity::class.java)
|
||||
.putExtra("userId", user[bindingAdapterPosition].id), null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UsersViewHolder {
|
||||
return UsersViewHolder(
|
||||
ItemFollowerBinding.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.profileBannerImage.loadImage(user.banner)
|
||||
b.profileUserName.text = user.name
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = user.size
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue