Package app
Class MediaCommunicator
java.lang.Object
app.MediaCommunicator
Main facade class.
Users of this class can submit the creation/modification/deletion of Media entities as well as request that changes be saved to whatever MediaStorage implementation is used.
The MediaCommunicator provides a central API for modifying Media and allows listening for changes made using its API via the MediaObserver interface.
-
Constructor Summary
ConstructorDescriptionMediaCommunicator
(MediaStorage storage) Instantiate a MediaCommunicator with the given storage backend. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a MediaObserver to this MediaCommunicator.void
deleteMedia
(long id) Remove the Media object with the given name.getIDsWithin
(double x, double y, double w, double h) Return a set containing at least the IDs of all the Media objects within the rectangular region with top left corner at (`x`, `y`) and with width `w` and height `h`.getMedia
(long id) Return the Media object with the given ID.void
Remove a MediaObserver from this MediaCommunicator.void
save()
Save changes to storage.void
updateMedia
(Media media) Update (or add, if it doesn't already exist) the given Media object.void
updateMedia
(Media media, Consumer<Long> idCallback) Update (or add, if it doesn't already exist) the given Media object.
-
Constructor Details
-
MediaCommunicator
Instantiate a MediaCommunicator with the given storage backend.
-
-
Method Details
-
addObserver
Add a MediaObserver to this MediaCommunicator. The added MediaObserver will be notified whenever Media is added/modified/removed via this MediaCommunicator. -
removeObserver
Remove a MediaObserver from this MediaCommunicator. The removed MediaObserver will no longer be notified of any changes to Media made via this MediaCommunicator. -
updateMedia
Update (or add, if it doesn't already exist) the given Media object.If the given Media does not yet have an assigned ID, an ID will be generated and the method passed as `idCallback` will be called with the generated ID as its argument before any MediaObservers are notified of the new Media.
- Throws:
Exception
-
updateMedia
Update (or add, if it doesn't already exist) the given Media object.- Throws:
Exception
-
deleteMedia
public void deleteMedia(long id) Remove the Media object with the given name. -
getIDsWithin
Return a set containing at least the IDs of all the Media objects within the rectangular region with top left corner at (`x`, `y`) and with width `w` and height `h`.- Throws:
Exception
-
getMedia
Return the Media object with the given ID.- Throws:
Exception
-
save
Save changes to storage.- Throws:
Exception
-