[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/18443: Move viewholders to separate files and package
parent
5f2ac9fbc0
commit
debb6bbc7b
@ -0,0 +1,23 @@
|
||||
/* 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.tabstray.viewholders
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import org.mozilla.fenix.tabstray.TrayPagerAdapter
|
||||
|
||||
/**
|
||||
* An abstract [RecyclerView.ViewHolder] for [TrayPagerAdapter] items.
|
||||
*/
|
||||
abstract class AbstractTrayViewHolder constructor(
|
||||
override val containerView: View
|
||||
) : RecyclerView.ViewHolder(containerView), LayoutContainer {
|
||||
|
||||
abstract fun bind(
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder>,
|
||||
layoutManager: RecyclerView.LayoutManager
|
||||
)
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/* 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.tabstray.viewholders
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
import org.mozilla.fenix.tabstray.browser.BaseBrowserTrayList
|
||||
|
||||
/**
|
||||
* A shared view holder for browser tabs tray list.
|
||||
*/
|
||||
abstract class BaseBrowserTabViewHolder(
|
||||
containerView: View,
|
||||
interactor: TabsTrayInteractor
|
||||
) : AbstractTrayViewHolder(containerView) {
|
||||
|
||||
protected val trayList: BaseBrowserTrayList = itemView.findViewById(R.id.tray_list_item)
|
||||
|
||||
init {
|
||||
trayList.interactor = interactor
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun bind(
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder>,
|
||||
layoutManager: RecyclerView.LayoutManager
|
||||
) {
|
||||
trayList.layoutManager = layoutManager
|
||||
trayList.adapter = adapter
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/* 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.tabstray.viewholders
|
||||
|
||||
import android.view.View
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
|
||||
/**
|
||||
* View holder for the private tabs tray list.
|
||||
*/
|
||||
class PrivateBrowserTabViewHolder(
|
||||
containerView: View,
|
||||
interactor: TabsTrayInteractor
|
||||
) : BaseBrowserTabViewHolder(containerView, interactor) {
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.private_browser_tray_list
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue