Issue #18774: Move SelectionInteractor to new package

The interactor and holder are useful outside of the `library` package, so
let's move it up a package level for other components.
upstream-sync
Jonathan Almeida 3 years ago committed by Jonathan Almeida
parent 233b909b81
commit 499aa858b2

@ -19,34 +19,8 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.ext.loadIntoView
/**
* Interactor for items that can be selected on the bookmarks and history screens.
*/
interface SelectionInteractor<T> {
/**
* Called when an item is tapped to open it.
* @param item the tapped item to open.
*/
fun open(item: T)
/**
* Called when an item is long pressed and selection mode is started,
* or when selection mode has already started an an item is tapped.
* @param item the item to select.
*/
fun select(item: T)
/**
* Called when a selected item is tapped in selection mode and should no longer be selected.
* @param item the item to deselect.
*/
fun deselect(item: T)
}
interface SelectionHolder<T> {
val selectedItems: Set<T>
}
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.selection.SelectionInteractor
class LibrarySiteItemView @JvmOverloads constructor(
context: Context,

@ -9,7 +9,7 @@ import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.lib.state.Action
import mozilla.components.lib.state.State
import mozilla.components.lib.state.Store
import org.mozilla.fenix.library.SelectionHolder
import org.mozilla.fenix.selection.SelectionHolder
class BookmarkFragmentStore(
initialState: BookmarkFragmentState

@ -16,7 +16,7 @@ import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.library.LibraryPageView
import org.mozilla.fenix.library.SelectionInteractor
import org.mozilla.fenix.selection.SelectionInteractor
/**
* Interface for the Bookmarks view.

@ -8,7 +8,7 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import org.mozilla.fenix.library.SelectionHolder
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.library.downloads.viewholders.DownloadsListItemViewHolder
class DownloadAdapter(

@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.component_history.view.swipe_refresh
import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.R
import org.mozilla.fenix.library.LibraryPageView
import org.mozilla.fenix.library.SelectionInteractor
import org.mozilla.fenix.selection.SelectionInteractor
/**
* Interface for the DownloadViewInteractor. This interface is implemented by objects that want

@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.download_list_item.view.*
import kotlinx.android.synthetic.main.library_site_item.view.*
import mozilla.components.feature.downloads.toMegabyteOrKilobyteString
import org.mozilla.fenix.R
import org.mozilla.fenix.library.SelectionHolder
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.library.downloads.DownloadInteractor
import org.mozilla.fenix.library.downloads.DownloadItem
import org.mozilla.fenix.ext.getIcon

@ -11,7 +11,7 @@ import android.view.ViewGroup
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import org.mozilla.fenix.R
import org.mozilla.fenix.library.SelectionHolder
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.library.history.viewholders.HistoryListItemViewHolder
import java.util.Calendar
import java.util.Date

@ -17,7 +17,7 @@ import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.library.LibraryPageView
import org.mozilla.fenix.library.SelectionInteractor
import org.mozilla.fenix.selection.SelectionInteractor
import org.mozilla.fenix.theme.ThemeManager
/**

@ -15,7 +15,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.hideAndDisable
import org.mozilla.fenix.ext.showAndEnable
import org.mozilla.fenix.library.SelectionHolder
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.library.history.HistoryFragmentState
import org.mozilla.fenix.library.history.HistoryInteractor
import org.mozilla.fenix.library.history.HistoryItem

@ -0,0 +1,12 @@
/* 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.selection
/**
* Contains the selection of items added or removed using the [SelectionInteractor].
*/
interface SelectionHolder<T> {
val selectedItems: Set<T>
}

@ -0,0 +1,29 @@
/* 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.selection
/**
* Interactor for items that can be selected on the bookmarks and history screens.
*/
interface SelectionInteractor<T> {
/**
* Called when an item is tapped to open it.
* @param item the tapped item to open.
*/
fun open(item: T)
/**
* Called when an item is long pressed and selection mode is started,
* or when selection mode has already started an an item is tapped.
* @param item the item to select.
*/
fun select(item: T)
/**
* Called when a selected item is tapped in selection mode and should no longer be selected.
* @param item the item to deselect.
*/
fun deselect(item: T)
}
Loading…
Cancel
Save