質問編集履歴
1
情報の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,10 +38,92 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
[
|
41
|
+
[RecyclerAdapter(継承先のAdapter)]
|
42
42
|
|
43
43
|
```Kotlin
|
44
44
|
|
45
|
+
class MusicRecyclerHolder(itemView: View): RecyclerView.ViewHolder(itemView){
|
46
|
+
|
47
|
+
val artwork = itemView.findViewById<ImageButton>(R.id.VSL_ArtImage)
|
48
|
+
|
49
|
+
val musicTitle = itemView.findViewById<TextView>(R.id.VSL_Title)
|
50
|
+
|
51
|
+
val musicText =itemView.findViewById<TextView>(R.id.VSL_TitleSec)
|
52
|
+
|
53
|
+
val menuIcon = itemView.findViewById<ImageButton>(R.id.VSL_Menu)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
interface ListListener{
|
58
|
+
|
59
|
+
fun onItemClick(tappedView: View?, viewHolder: MusicRecyclerHolder?, musicData: MusicData?)
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
class MusicRecyclerAdapter(
|
68
|
+
|
69
|
+
private val context: Context,
|
70
|
+
|
71
|
+
private val dataList: List<MusicData>,
|
72
|
+
|
73
|
+
private val isShowArtist: Boolean,
|
74
|
+
|
75
|
+
private val listener: MusicRecyclerHolder.ListListener
|
76
|
+
|
77
|
+
): HFRecyclerAdapter<MusicRecyclerHolder>() {
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
override fun onCreateItemViewHolder(parent: ViewGroup, viewType: Int): MusicRecyclerHolder {
|
82
|
+
|
83
|
+
return MusicRecyclerHolder(LayoutInflater.from(parent.context).inflate(R.layout.view_song_list, parent, false))
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
override fun onBindItemViewHolder(viewHolder: Any, position: Int, isHF: Boolean) {
|
90
|
+
|
91
|
+
if (!isHF && viewHolder is MusicRecyclerHolder) {
|
92
|
+
|
93
|
+
val data = dataList[position]
|
94
|
+
|
95
|
+
with(viewHolder) {
|
96
|
+
|
97
|
+
//リスナー付けたり色々処理
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
} else if(viewHolder is RecyclerView.ViewHolder){
|
102
|
+
|
103
|
+
viewHolder.itemView.setOnClickListener {
|
104
|
+
|
105
|
+
listener.onItemClick(null, null, null) //ヘッダーフッター
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
override fun getNormalItemCount(): Int = dataList.size
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
[HFRecyclerAdapter(今回問題の継承元Adapter)]
|
124
|
+
|
125
|
+
```Kotlin
|
126
|
+
|
45
127
|
abstract class HFRecyclerAdapter<ViewHolder: RecyclerView.ViewHolder>: RecyclerView.Adapter<RecyclerView.ViewHolder>(){
|
46
128
|
|
47
129
|
|