Commit 584b1e4 1 parent f119784 commit 584b1e4 Copy full SHA for 584b1e4
File tree 1 file changed +15
-13
lines changed
app/src/main/java/com/example/myapplication
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -19,18 +19,7 @@ class ImagePickerAdapter(
19
19
20
20
21
21
inner class ViewHolder (itemView : View ) : RecyclerView.ViewHolder(itemView) {
22
- private val ivCustomImage = itemView.findViewById<ImageView >(R .id.ivCustomImage)
23
22
24
- fun bind (uri : Uri ) {
25
- ivCustomImage.setImageURI(uri)
26
- ivCustomImage.setOnClickListener(null )
27
- }
28
-
29
- fun bind () {
30
- ivCustomImage.setOnClickListener {
31
-
32
- }
33
- }
34
23
}
35
24
36
25
override fun onCreateViewHolder (parent : ViewGroup , viewType : Int ): RecyclerView .ViewHolder {
@@ -46,12 +35,25 @@ class ImagePickerAdapter(
46
35
47
36
override fun getItemCount (): Int = boardSize.getNumPairs()
48
37
49
- override fun onBindViewHolder (holder : ViewHolder , position : Int ) {
38
+ override fun onBindViewHolder (holder : RecyclerView . ViewHolder , position : Int ) {
50
39
if (position < imageUris.size) {
51
40
holder.bind(imageUris[position])
52
41
}
53
42
else {
54
- holder.bind ()
43
+ holder.bindNothing ()
55
44
}
56
45
}
57
46
}
47
+
48
+ private fun RecyclerView.ViewHolder.bindNothing () {
49
+ val ivCustomImage = itemView.findViewById<ImageView >(R .id.ivCustomImage)
50
+ ivCustomImage.setOnClickListener {
51
+
52
+ }
53
+ }
54
+
55
+ private fun RecyclerView.ViewHolder.bind (uri : Uri ) {
56
+ val ivCustomImage = itemView.findViewById<ImageView >(R .id.ivCustomImage)
57
+ ivCustomImage.setImageURI(uri)
58
+ ivCustomImage.setOnClickListener(null )
59
+ }
You can’t perform that action at this time.
0 commit comments