Class RecentlyViewedManager
java.lang.Object
org.troy.capstone.managers.RecentlyViewedManager
- All Implemented Interfaces:
SearchedItemPanelInteractor
Manager for recently viewed items, bridges
RecentlyViewedQueue and RecentlyViewedWindow. Handles adding items to the recently viewed queue and updating the window content accordingly without the window and queue depending on each other.
Implements SearchedItemPanelInteractor to listen for item selection events from the searched item panels, allowing it to update the recently viewed content based on user interactions with the search results.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RecentlyViewedQueueQueue to manage recently viewed items.private final RecentlyViewedWindowWindow to display recently viewed items. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateRecentlyViewedManager(ItemRepo itemRepo, RecentlyViewedWindow recentlyViewedWindow) Constructor for theRecentlyViewedManager. -
Method Summary
Modifier and TypeMethodDescription(package private) static RecentlyViewedManagercreate(ItemRepo itemRepo, SearchedItemPanelDestinationUI destinationUI, SearchedItemPanelSourceUI panelSourceUI) Factory method to create aRecentlyViewedManagerand attach it as a listener to the givenSearchedItemPanelSourceUI, allowing to receive item selection events from within theSearchedItemPanelSourceUI.voidonItemSelected(String itemId) Called when an item is selected in the searched item panel.
-
Field Details
-
recentlyViewedQueue
Queue to manage recently viewed items. -
recentlyViewedWindow
Window to display recently viewed items.
-
-
Constructor Details
-
RecentlyViewedManager
Constructor for theRecentlyViewedManager.- Parameters:
itemRepo- TheItemRepoto use for retrieving item details.recentlyViewedWindow- TheRecentlyViewedWindowto use for displaying recently viewed items.
-
-
Method Details
-
create
static RecentlyViewedManager create(ItemRepo itemRepo, SearchedItemPanelDestinationUI destinationUI, SearchedItemPanelSourceUI panelSourceUI) Factory method to create aRecentlyViewedManagerand attach it as a listener to the givenSearchedItemPanelSourceUI, allowing to receive item selection events from within theSearchedItemPanelSourceUI.- Parameters:
itemRepo- TheItemRepoto use for retrieving item details.destinationUI- TheSearchedItemPanelDestinationUIto use for displaying recently viewed items, should be the same instance asrecentlyViewedWindowbut typed as the interface it implements.panelSourceUI- TheSearchedItemPanelSourceUIto register as a listener to receive item selection events from the searched item panels, should be the same instance as theSearchedItemPaginationbut typed as the interface it implements.- Returns:
- A new instance of
RecentlyViewedManagerwith the given parameters, and registered as a listener to thepanelSourceUI. - Preconditions:
- itemRepo, recentlyViewedWindow, and panelSourceUI are not null. destinationUI is an instance of
RecentlyViewedWindowand panelSourceUI is an instance ofSearchedItemPagination.
-
onItemSelected
Called when an item is selected in the searched item panel. Adds the selected item to the recently viewed queue and updates the recently viewed window content accordingly.- Specified by:
onItemSelectedin interfaceSearchedItemPanelInteractor- Parameters:
itemId- The ID of the selected item.- Preconditions:
- itemId is not null and corresponds to a valid key in the
ItemHashMap.
-