You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
Kotlin
40 lines
1.3 KiB
Kotlin
5 years ago
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
|
||
|
package org.mozilla.fenix.settings.about
|
||
|
|
||
|
import android.view.LayoutInflater
|
||
|
import android.view.ViewGroup
|
||
|
import androidx.recyclerview.widget.RecyclerView
|
||
|
import org.mozilla.fenix.settings.about.viewholders.AboutItemViewHolder
|
||
|
|
||
|
class AboutPageAdapter(private val listener: AboutPageListener) : RecyclerView.Adapter<AboutItemViewHolder>() {
|
||
|
|
||
|
private var aboutList: List<AboutPageItem>? = null
|
||
|
|
||
|
fun updateData(items: List<AboutPageItem>) {
|
||
|
this.aboutList = items
|
||
|
notifyDataSetChanged()
|
||
|
}
|
||
|
|
||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AboutItemViewHolder {
|
||
|
val view = LayoutInflater.from(parent.context)
|
||
|
.inflate(AboutItemViewHolder.LAYOUT_ID, parent, false)
|
||
|
|
||
|
return AboutItemViewHolder(view, listener)
|
||
|
}
|
||
|
|
||
|
override fun getItemCount(): Int = aboutList?.size ?: 0
|
||
|
|
||
|
override fun onBindViewHolder(holder: AboutItemViewHolder, position: Int) {
|
||
|
(aboutList?.get(position) as AboutPageItem.Item).also {
|
||
|
holder.bind(it)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
interface AboutPageListener {
|
||
|
fun onAboutItemClicked(item: AboutItem)
|
||
|
}
|