2019-12-30 20:39:04 +01:00
|
|
|
/* 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.home.sessioncontrol.viewholders
|
|
|
|
|
|
|
|
import android.view.View
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
2020-03-09 15:22:38 +01:00
|
|
|
import com.google.android.flexbox.FlexboxLayoutManager
|
2019-12-30 20:39:04 +01:00
|
|
|
import kotlinx.android.synthetic.main.component_top_sites.view.*
|
|
|
|
import mozilla.components.feature.top.sites.TopSite
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
|
|
|
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.topsites.TopSitesAdapter
|
|
|
|
|
|
|
|
class TopSiteViewHolder(
|
|
|
|
view: View,
|
2020-05-12 23:05:08 +02:00
|
|
|
interactor: TopSiteInteractor
|
|
|
|
) : RecyclerView.ViewHolder(view) {
|
|
|
|
|
2019-12-30 20:39:04 +01:00
|
|
|
private val topSitesAdapter = TopSitesAdapter(interactor)
|
|
|
|
|
|
|
|
init {
|
|
|
|
view.top_sites_list.apply {
|
|
|
|
adapter = topSitesAdapter
|
2020-03-09 15:22:38 +01:00
|
|
|
layoutManager = FlexboxLayoutManager(view.context)
|
2020-02-27 00:11:17 +01:00
|
|
|
isNestedScrollingEnabled = false
|
2019-12-30 20:39:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun bind(topSites: List<TopSite>) {
|
|
|
|
topSitesAdapter.submitList(topSites)
|
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
const val LAYOUT_ID = R.layout.component_top_sites
|
|
|
|
}
|
|
|
|
}
|