Issue #18931: Rename class to CollectionsListAdapter

upstream-sync
Jonathan Almeida 3 years ago committed by Jonathan Almeida
parent 5db2f7568f
commit f1e7c1130b

@ -14,10 +14,14 @@ import androidx.recyclerview.widget.RecyclerView
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
import org.mozilla.fenix.R
internal class CollectionsAdapter(
/**
* An adapter for displaying an option to create a new collection and the list of existing
* collections.
*/
class CollectionsListAdapter(
private val collections: Array<String>,
private val onNewCollectionClicked: () -> Unit
) : RecyclerView.Adapter<CollectionsAdapter.CollectionItemViewHolder>() {
) : RecyclerView.Adapter<CollectionsListAdapter.CollectionItemViewHolder>() {
@VisibleForTesting
internal var checkedPosition = 1

@ -432,7 +432,7 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), UserInteractionHandler
.setView(customLayout)
.setPositiveButton(android.R.string.ok) { dialog, _ ->
val selectedCollection =
(list.adapter as CollectionsAdapter).getSelectedCollection()
(list.adapter as CollectionsListAdapter).getSelectedCollection()
val collection = tabCollectionStorage.cachedTabCollections[selectedCollection]
viewLifecycleOwner.lifecycleScope.launch(Main) {
tabCollectionStorage.addTabsToCollection(collection, sessionList)
@ -452,7 +452,7 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), UserInteractionHandler
val dialog = builder.create()
val adapter =
CollectionsAdapter(arrayOf(it.getString(R.string.tab_tray_add_new_collection)) + collections) {
CollectionsListAdapter(arrayOf(it.getString(R.string.tab_tray_add_new_collection)) + collections) {
dialog.dismiss()
showAddNewCollectionDialog(sessionList)
}

@ -14,7 +14,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class CollectionsAdapterTest {
class CollectionsListAdapterTest {
private val collectionList: Array<String> =
arrayOf(
"Add new collection",
@ -25,14 +25,14 @@ class CollectionsAdapterTest {
@Test
fun `getItemCount should return the correct list size`() {
val adapter = CollectionsAdapter(collectionList, onNewCollectionClicked)
val adapter = CollectionsListAdapter(collectionList, onNewCollectionClicked)
assertEquals(3, adapter.itemCount)
}
@Test
fun `getSelectedCollection should account for add new collection when returning right item`() {
val adapter = CollectionsAdapter(collectionList, onNewCollectionClicked)
val adapter = CollectionsListAdapter(collectionList, onNewCollectionClicked)
// first collection by default
assertEquals(1, adapter.checkedPosition)
@ -44,7 +44,7 @@ class CollectionsAdapterTest {
@Test
fun `creates and binds viewholder`() {
val adapter = CollectionsAdapter(collectionList, onNewCollectionClicked)
val adapter = CollectionsListAdapter(collectionList, onNewCollectionClicked)
val holder1 = adapter.createViewHolder(FrameLayout(testContext), 0)
val holder2 = adapter.createViewHolder(FrameLayout(testContext), 0)
Loading…
Cancel
Save