From 865394cffe572d2b5f71bcc35259b6d0ec14ccb5 Mon Sep 17 00:00:00 2001
From: Taras Smakula <tarassmakula@gmail.com>
Date: Tue, 26 Dec 2023 16:19:18 +0200
Subject: [PATCH] Create adapter

---
 .../room/invites/list/InvitesAdapter.kt       | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 core/src/main/java/org/futo/circles/core/feature/room/invites/list/InvitesAdapter.kt

diff --git a/core/src/main/java/org/futo/circles/core/feature/room/invites/list/InvitesAdapter.kt b/core/src/main/java/org/futo/circles/core/feature/room/invites/list/InvitesAdapter.kt
new file mode 100644
index 000000000..95e490b3b
--- /dev/null
+++ b/core/src/main/java/org/futo/circles/core/feature/room/invites/list/InvitesAdapter.kt
@@ -0,0 +1,59 @@
+package org.futo.circles.core.feature.room.invites.list
+
+import android.view.ViewGroup
+import org.futo.circles.core.base.list.BaseRvAdapter
+import org.futo.circles.core.model.InviteListItem
+import org.futo.circles.core.model.InviteTypeArg
+
+
+class InvitesAdapter(
+    private val onInviteClicked: (InviteListItem, Boolean) -> Unit,
+    private val onUnblurProfileIconClicked: (InviteListItem) -> Unit
+) : BaseRvAdapter<InviteListItem, InviteViewHolder>(DefaultIdEntityCallback()) {
+
+    override fun getItemViewType(position: Int): Int = getItem(position).inviteType.ordinal
+
+    override fun onCreateViewHolder(
+        parent: ViewGroup,
+        viewType: Int
+    ) = when (InviteTypeArg.entries[viewType]) {
+        InviteTypeArg.Circle -> InvitedCircleViewHolder(
+            parent = parent,
+            onInviteClicked = { position, isAccepted ->
+                onInviteClicked(getItem(position), isAccepted)
+            },
+            onShowProfileIconClicked = { position ->
+                onUnblurProfileIconClicked(getItem(position))
+            })
+
+        InviteTypeArg.Group -> InvitedGroupViewHolder(
+            parent = parent,
+            onInviteClicked = { position, isAccepted ->
+                onInviteClicked(getItem(position), isAccepted)
+            },
+            onShowProfileIconClicked = { position ->
+                onUnblurProfileIconClicked(getItem(position))
+            })
+
+        InviteTypeArg.Photo -> InvitedGalleryViewHolder(
+            parent = parent,
+            onInviteClicked = { position, isAccepted ->
+                onInviteClicked(getItem(position), isAccepted)
+            },
+            onShowProfileIconClicked = { position ->
+                onUnblurProfileIconClicked(getItem(position))
+            })
+
+        InviteTypeArg.People -> FollowRequestViewHolder(
+            parent = parent,
+            onRequestClicked = { position, isAccepted ->
+                onInviteClicked(getItem(position), isAccepted)
+            })
+    }
+
+
+    override fun onBindViewHolder(holder: InviteViewHolder, position: Int) {
+        holder.bind(getItem(position))
+    }
+
+}
\ No newline at end of file
-- 
GitLab