FollowRequestsAdapter.kt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright 2021 Tusky Contributors
  2. *
  3. * This file is a part of Tusky.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it under the terms of the
  6. * GNU General Public License as published by the Free Software Foundation; either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  10. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  11. * Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with Tusky; if not,
  14. * see <http://www.gnu.org/licenses>. */
  15. package com.keylesspalace.tusky.components.accountlist.adapter
  16. import android.view.LayoutInflater
  17. import android.view.ViewGroup
  18. import com.keylesspalace.tusky.adapter.FollowRequestViewHolder
  19. import com.keylesspalace.tusky.databinding.ItemFollowRequestBinding
  20. import com.keylesspalace.tusky.interfaces.AccountActionListener
  21. /** Displays a list of follow requests with accept/reject buttons. */
  22. class FollowRequestsAdapter(
  23. accountActionListener: AccountActionListener,
  24. animateAvatar: Boolean,
  25. animateEmojis: Boolean,
  26. showBotOverlay: Boolean
  27. ) : AccountAdapter<FollowRequestViewHolder>(
  28. accountActionListener = accountActionListener,
  29. animateAvatar = animateAvatar,
  30. animateEmojis = animateEmojis,
  31. showBotOverlay = showBotOverlay
  32. ) {
  33. override fun createAccountViewHolder(parent: ViewGroup): FollowRequestViewHolder {
  34. val binding = ItemFollowRequestBinding.inflate(
  35. LayoutInflater.from(parent.context), parent, false
  36. )
  37. return FollowRequestViewHolder(
  38. binding,
  39. accountActionListener,
  40. showHeader = false
  41. )
  42. }
  43. override fun onBindAccountViewHolder(viewHolder: FollowRequestViewHolder, position: Int) {
  44. viewHolder.setupWithAccount(
  45. account = accountList[position],
  46. animateAvatar = animateAvatar,
  47. animateEmojis = animateEmojis,
  48. showBotOverlay = showBotOverlay
  49. )
  50. viewHolder.setupActionListener(accountActionListener, accountList[position].id)
  51. }
  52. }