feat: Tapping followed hashtag names in lists opens relevant timeline

This commit is contained in:
Nik Clayton 2024-03-11 20:19:17 +01:00
parent 4762411147
commit 65a0fb19d9
3 changed files with 15 additions and 6 deletions

View File

@ -19,6 +19,7 @@ import app.pachli.core.common.extensions.hide
import app.pachli.core.common.extensions.show import app.pachli.core.common.extensions.show
import app.pachli.core.common.extensions.viewBinding import app.pachli.core.common.extensions.viewBinding
import app.pachli.core.common.extensions.visible import app.pachli.core.common.extensions.visible
import app.pachli.core.navigation.StatusListActivityIntent
import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.network.retrofit.MastodonApi
import app.pachli.core.preferences.PrefKeys import app.pachli.core.preferences.PrefKeys
import app.pachli.databinding.ActivityFollowedTagsBinding 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<ComposeAutoCompleteAdapter.AutocompleteResult> { override suspend fun search(token: String): List<ComposeAutoCompleteAdapter.AutocompleteResult> {
return viewModel.searchAutocompleteSuggestions(token) return viewModel.searchAutocompleteSuggestions(token)
} }

View File

@ -2,11 +2,8 @@ package app.pachli.components.followedtags
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.TextView
import androidx.paging.PagingDataAdapter import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import app.pachli.R
import app.pachli.databinding.ItemFollowedHashtagBinding import app.pachli.databinding.ItemFollowedHashtagBinding
import app.pachli.interfaces.HashtagActionListener import app.pachli.interfaces.HashtagActionListener
import app.pachli.util.BindingHolder import app.pachli.util.BindingHolder
@ -20,9 +17,15 @@ class FollowedTagsAdapter(
override fun onBindViewHolder(holder: BindingHolder<ItemFollowedHashtagBinding>, position: Int) { override fun onBindViewHolder(holder: BindingHolder<ItemFollowedHashtagBinding>, position: Int) {
viewModel.tags[position].let { tag -> viewModel.tags[position].let { tag ->
holder.itemView.findViewById<TextView>(R.id.followed_tag).text = tag.name with(holder.binding) {
holder.itemView.findViewById<ImageButton>(R.id.followed_tag_unfollow).setOnClickListener { followedTag.text = tag.name
actionListener.unfollow(tag.name, holder.bindingAdapterPosition) followedTag.setOnClickListener {
actionListener.onViewTag(tag.name)
}
followedTagUnfollow.setOnClickListener {
actionListener.unfollow(tag.name, holder.bindingAdapterPosition)
}
} }
} }
} }

View File

@ -2,4 +2,5 @@ package app.pachli.interfaces
interface HashtagActionListener { interface HashtagActionListener {
fun unfollow(tagName: String, position: Int) fun unfollow(tagName: String, position: Int)
fun onViewTag(tag: String)
} }