Skip to content

Commit 6e6b6fc

Browse files
committed
♻️ NotificationAdapter 코드 정리
1 parent 2f44fb2 commit 6e6b6fc

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

presentation/src/main/java/com/whyranoid/presentation/community/group/detail/GroupNotificationAdapter.kt

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ class GroupNotificationAdapter(private val myUid: String) :
4545
abstract fun bind(notification: GroupNotification)
4646
}
4747

48-
class MyStartNotificationViewHolder(private val binding: MyStartNotificationItemBinding) :
48+
class MyStartNotificationViewHolder(
49+
parent: ViewGroup,
50+
private val binding: MyStartNotificationItemBinding = MyStartNotificationItemBinding.inflate(
51+
LayoutInflater.from(parent.context),
52+
parent,
53+
false
54+
)
55+
) :
4956
NotificationViewHolder(binding) {
5057

5158
override fun bind(notification: GroupNotification) {
@@ -55,7 +62,14 @@ class GroupNotificationAdapter(private val myUid: String) :
5562
}
5663
}
5764

58-
class MyFinishNotificationViewHolder(private val binding: MyFinishNotificationItemBinding) :
65+
class MyFinishNotificationViewHolder(
66+
parent: ViewGroup,
67+
private val binding: MyFinishNotificationItemBinding = MyFinishNotificationItemBinding.inflate(
68+
LayoutInflater.from(parent.context),
69+
parent,
70+
false
71+
)
72+
) :
5973
NotificationViewHolder(binding) {
6074

6175
override fun bind(notification: GroupNotification) {
@@ -65,7 +79,14 @@ class GroupNotificationAdapter(private val myUid: String) :
6579
}
6680
}
6781

68-
class OtherStartNotificationViewHolder(private val binding: OtherStartNotificationItemBinding) :
82+
class OtherStartNotificationViewHolder(
83+
parent: ViewGroup,
84+
private val binding: OtherStartNotificationItemBinding = OtherStartNotificationItemBinding.inflate(
85+
LayoutInflater.from(parent.context),
86+
parent,
87+
false
88+
)
89+
) :
6990
NotificationViewHolder(binding) {
7091

7192
override fun bind(notification: GroupNotification) {
@@ -75,7 +96,14 @@ class GroupNotificationAdapter(private val myUid: String) :
7596
}
7697
}
7798

78-
class OtherFinishNotificationViewHolder(private val binding: OtherFinishNotificationItemBinding) :
99+
class OtherFinishNotificationViewHolder(
100+
parent: ViewGroup,
101+
private val binding: OtherFinishNotificationItemBinding = OtherFinishNotificationItemBinding.inflate(
102+
LayoutInflater.from(parent.context),
103+
parent,
104+
false
105+
)
106+
) :
79107
NotificationViewHolder(binding) {
80108

81109
override fun bind(notification: GroupNotification) {
@@ -100,42 +128,10 @@ class GroupNotificationAdapter(private val myUid: String) :
100128

101129
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NotificationViewHolder {
102130
return when (viewType) {
103-
MY_START_NOTIFICATION_TYPE -> {
104-
val layoutInflater =
105-
MyStartNotificationItemBinding.inflate(
106-
LayoutInflater.from(parent.context),
107-
parent,
108-
false
109-
)
110-
MyStartNotificationViewHolder(layoutInflater)
111-
}
112-
MY_FINISH_NOTIFICATION_TYPE -> {
113-
val layoutInflater =
114-
MyFinishNotificationItemBinding.inflate(
115-
LayoutInflater.from(parent.context),
116-
parent,
117-
false
118-
)
119-
MyFinishNotificationViewHolder(layoutInflater)
120-
}
121-
OTHER_START_NOTIFICATION_TYPE -> {
122-
val layoutInflater =
123-
OtherStartNotificationItemBinding.inflate(
124-
LayoutInflater.from(parent.context),
125-
parent,
126-
false
127-
)
128-
OtherStartNotificationViewHolder(layoutInflater)
129-
}
130-
else -> {
131-
val layoutInflater =
132-
OtherFinishNotificationItemBinding.inflate(
133-
LayoutInflater.from(parent.context),
134-
parent,
135-
false
136-
)
137-
OtherFinishNotificationViewHolder(layoutInflater)
138-
}
131+
MY_START_NOTIFICATION_TYPE -> MyStartNotificationViewHolder(parent)
132+
MY_FINISH_NOTIFICATION_TYPE -> MyFinishNotificationViewHolder(parent)
133+
OTHER_START_NOTIFICATION_TYPE -> OtherStartNotificationViewHolder(parent)
134+
else -> OtherFinishNotificationViewHolder(parent)
139135
}
140136
}
141137

0 commit comments

Comments
 (0)