@@ -45,7 +45,14 @@ class GroupNotificationAdapter(private val myUid: String) :
45
45
abstract fun bind (notification : GroupNotification )
46
46
}
47
47
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
+ ) :
49
56
NotificationViewHolder (binding) {
50
57
51
58
override fun bind (notification : GroupNotification ) {
@@ -55,7 +62,14 @@ class GroupNotificationAdapter(private val myUid: String) :
55
62
}
56
63
}
57
64
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
+ ) :
59
73
NotificationViewHolder (binding) {
60
74
61
75
override fun bind (notification : GroupNotification ) {
@@ -65,7 +79,14 @@ class GroupNotificationAdapter(private val myUid: String) :
65
79
}
66
80
}
67
81
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
+ ) :
69
90
NotificationViewHolder (binding) {
70
91
71
92
override fun bind (notification : GroupNotification ) {
@@ -75,7 +96,14 @@ class GroupNotificationAdapter(private val myUid: String) :
75
96
}
76
97
}
77
98
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
+ ) :
79
107
NotificationViewHolder (binding) {
80
108
81
109
override fun bind (notification : GroupNotification ) {
@@ -100,42 +128,10 @@ class GroupNotificationAdapter(private val myUid: String) :
100
128
101
129
override fun onCreateViewHolder (parent : ViewGroup , viewType : Int ): NotificationViewHolder {
102
130
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)
139
135
}
140
136
}
141
137
0 commit comments