From 65a0fb19d9f43b96f446d79834057ed77e5e4904 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 11 Mar 2024 20:19:17 +0100 Subject: [PATCH] feat: Tapping followed hashtag names in lists opens relevant timeline --- .../followedtags/FollowedTagsActivity.kt | 5 +++++ .../followedtags/FollowedTagsAdapter.kt | 15 +++++++++------ .../pachli/interfaces/HashtagActionListener.kt | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/pachli/components/followedtags/FollowedTagsActivity.kt b/app/src/main/java/app/pachli/components/followedtags/FollowedTagsActivity.kt index b2d79e08b..25b8347e5 100644 --- a/app/src/main/java/app/pachli/components/followedtags/FollowedTagsActivity.kt +++ b/app/src/main/java/app/pachli/components/followedtags/FollowedTagsActivity.kt @@ -19,6 +19,7 @@ import app.pachli.core.common.extensions.hide import app.pachli.core.common.extensions.show import app.pachli.core.common.extensions.viewBinding import app.pachli.core.common.extensions.visible +import app.pachli.core.navigation.StatusListActivityIntent import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.preferences.PrefKeys import app.pachli.databinding.ActivityFollowedTagsBinding @@ -170,6 +171,10 @@ class FollowedTagsActivity : } } + override fun onViewTag(tag: String) { + startActivityWithSlideInAnimation(StatusListActivityIntent.hashtag(this, tag)) + } + override suspend fun search(token: String): List { return viewModel.searchAutocompleteSuggestions(token) } diff --git a/app/src/main/java/app/pachli/components/followedtags/FollowedTagsAdapter.kt b/app/src/main/java/app/pachli/components/followedtags/FollowedTagsAdapter.kt index b86abe400..a517a18b7 100644 --- a/app/src/main/java/app/pachli/components/followedtags/FollowedTagsAdapter.kt +++ b/app/src/main/java/app/pachli/components/followedtags/FollowedTagsAdapter.kt @@ -2,11 +2,8 @@ package app.pachli.components.followedtags import android.view.LayoutInflater import android.view.ViewGroup -import android.widget.ImageButton -import android.widget.TextView import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil -import app.pachli.R import app.pachli.databinding.ItemFollowedHashtagBinding import app.pachli.interfaces.HashtagActionListener import app.pachli.util.BindingHolder @@ -20,9 +17,15 @@ class FollowedTagsAdapter( override fun onBindViewHolder(holder: BindingHolder, position: Int) { viewModel.tags[position].let { tag -> - holder.itemView.findViewById(R.id.followed_tag).text = tag.name - holder.itemView.findViewById(R.id.followed_tag_unfollow).setOnClickListener { - actionListener.unfollow(tag.name, holder.bindingAdapterPosition) + with(holder.binding) { + followedTag.text = tag.name + followedTag.setOnClickListener { + actionListener.onViewTag(tag.name) + } + + followedTagUnfollow.setOnClickListener { + actionListener.unfollow(tag.name, holder.bindingAdapterPosition) + } } } } diff --git a/app/src/main/java/app/pachli/interfaces/HashtagActionListener.kt b/app/src/main/java/app/pachli/interfaces/HashtagActionListener.kt index 4742e0672..09246680a 100644 --- a/app/src/main/java/app/pachli/interfaces/HashtagActionListener.kt +++ b/app/src/main/java/app/pachli/interfaces/HashtagActionListener.kt @@ -2,4 +2,5 @@ package app.pachli.interfaces interface HashtagActionListener { fun unfollow(tagName: String, position: Int) + fun onViewTag(tag: String) }