public abstract class MediaItemsAbstractController
extends java.lang.Object
Constructor and Description |
---|
MediaItemsAbstractController() |
Modifier and Type | Method and Description |
---|---|
void |
deleteAllMediaItemsInCategory(Category category)
Removes all media items in the given category
|
void |
deleteMediaItem(MediaItem mediaItem)
Removes a media item from the database
|
long |
getAllMediaItemsNumberInCategory(Category category)
Gets the count of all media items (tracked or completed) in this category
|
java.util.List<MediaItem> |
getCompletedMediaItemsInCategory(int page,
Category category)
Gets all completed media items in the given category
|
abstract int |
getCompleteOptionName()
String for the "I've done this" media item option
|
abstract int |
getDoingOptionName()
String for the "I'm doing this now" media item option
|
protected abstract java.lang.String |
getDurationDatabaseFieldName()
"Internal" getter (used in
getRandomMediaItem(Category, Long, List, List, String, int, int) ) |
MediaItem |
getMediaItemById(Category category,
java.lang.Long itemId)
Gets a media item by its ID in the given category
|
abstract FormMediaItemAbstractFragment |
getMediaItemFormFragment(java.lang.Long categoryId,
java.lang.Long mediaItemId,
boolean isEmpty)
Returns the fragment for the form of this media type
|
abstract MediaItemService |
getMediaItemService(Context context)
Getter
|
java.util.List<MediaItem> |
getMediaItemsReleasedToday(Category category)
Gets all media items whose release date is today
|
abstract SuggestionsAbstractFragment |
getMediaItemSuggestionsFragment(java.lang.Long categoryId)
Returns the fragment for the suggestions page of this media type
|
Subcategory[] |
getMediaTypeSubcategories()
The subcategories of this media type (= subcategories of each category of this media type)
|
abstract java.lang.Class |
getModelClass()
Getter
|
MediaItem |
getRandomCompletedMediaItem(Category category,
java.lang.Long idDifferentFromIfPossible,
java.lang.String genresContains,
int completedYearsAgo,
int minDuration,
int maxDuration)
Retrieves a random completed media item in the given category that satisfies the given constraints
|
MediaItem |
getRandomTrackedMediaItem(Category category,
java.lang.Long idDifferentFromIfPossible,
java.lang.String genresContains,
java.lang.Boolean owned,
int minDuration,
int maxDuration)
Retrieves a random tracked media item in the given category that satisfies the given constraints
|
abstract int |
getRedoOptionName()
String for the "I could redo this" media item option
|
java.util.List<MediaItem> |
getTrackedMediaItemsInCategory(int page,
Category category)
Gets all tracked media items in the given category
|
abstract MediaItem |
initializeEmptyMediaItem()
Initializes and returns a new (empty) object of this media type
|
void |
saveMediaItem(MediaItem mediaItem)
Inserts or updates a media item in the database
|
java.util.List<MediaItem> |
searchMediaItemsInCategory(int page,
Category category,
java.lang.String query,
java.lang.Boolean completed)
Searches for media items matching the given query
|
void |
setMediaItemAsCompleted(MediaItem mediaItem,
java.util.Date completionDate)
Sets a media item as completed with the given date
|
void |
setMediaItemAsDoingNow(MediaItem mediaItem,
boolean doingNow)
Sets a media item as "doing" (watching, reading, etc.) now
|
void |
setMediaItemAsOwned(MediaItem mediaItem,
boolean owned)
Sets a media item as owned by the user
|
void |
setMediaItemAsToRedo(MediaItem mediaItem)
Sets a media item as "possibly to redo" (i.e.
|
void |
setMediaItemOrderInSectionBeforeInserting(Category category,
MediaItem newMediaItem)
Called BEFORE inserting a new media item to compute its order value in its section
|
void |
setMediaItemOrderInSectionBeforeUpdatingImportanceLevel(Category category,
MediaItem updatedMediaItem)
Called BEFORE changing a media item importance level
NOTE: called e.g.
|
void |
setOrderInSectionAfterMove(Category category,
MediaItem movedMediaItem,
MediaItem previousMediaItemInSection,
MediaItem nextMediaItemInSection)
Called to update the order field (for the database) AFTER "movedMediaItem" has been moved in the list
|
void |
undoSetAsCompleted(MediaItem mediaItem)
Undoes a previous call to
setMediaItemAsCompleted(MediaItem, Date) |
void |
updateMediaItemCompletionDate(MediaItem mediaItem,
java.util.Date completionDate)
Updates a media item completion date
|
java.lang.String |
validateMediaItem(Context context,
MediaItem mediaItem)
Validates a media item, possibly fixing what is wrong or, if impossible, returning an error string
|
java.lang.String |
validateMediaItemDbRow(Context context,
java.util.HashMap<java.lang.String,java.lang.Object> values)
Like
validateMediaItem(Context, MediaItem) but with actual DB values |
protected abstract java.lang.String |
validateSpecificMediaItem(Context context,
MediaItem mediaItem)
Validation for media item implementations
|
protected abstract java.lang.String |
validateSpecificMediaItemDbRow(Context context,
java.util.HashMap<java.lang.String,java.lang.Object> values)
Validation for media item implementations
|
public abstract java.lang.Class getModelClass()
public abstract MediaItem initializeEmptyMediaItem()
public abstract MediaItemService getMediaItemService(Context context)
public abstract int getRedoOptionName()
public abstract int getCompleteOptionName()
public abstract int getDoingOptionName()
protected abstract java.lang.String getDurationDatabaseFieldName()
getRandomMediaItem(Category, Long, List, List, String, int, int)
)public Subcategory[] getMediaTypeSubcategories()
public abstract FormMediaItemAbstractFragment getMediaItemFormFragment(java.lang.Long categoryId, java.lang.Long mediaItemId, boolean isEmpty)
categoryId
- the ID of the media item categorymediaItemId
- null if adding new media item, the ID of the media item to edit otherwiseisEmpty
- true if the form should be empty (= no fields are displayed, only the action bar)public abstract SuggestionsAbstractFragment getMediaItemSuggestionsFragment(java.lang.Long categoryId)
categoryId
- the ID of the media item categorypublic java.util.List<MediaItem> getTrackedMediaItemsInCategory(int page, Category category)
page
- the current page for the media items (e.g. 0 retrieves the first "PAGE_LENGTH" elements, 1 the elements from PAGE_LENGTH to 2*PAGE_LENGTH-1, etc.)category
- the media items categorypublic java.util.List<MediaItem> getCompletedMediaItemsInCategory(int page, Category category)
page
- the current page for the media items (e.g. 0 retrieves the first "PAGE_LENGTH" elements, 1 the elements from PAGE_LENGTH to 2*PAGE_LENGTH-1, etc.)category
- the media items categorypublic java.util.List<MediaItem> searchMediaItemsInCategory(int page, Category category, java.lang.String query, java.lang.Boolean completed)
page
- the current page for the media items (e.g. 0 retrieves the first "PAGE_LENGTH" elements, 1 the elements from PAGE_LENGTH to 2*PAGE_LENGTH-1, etc.)category
- the media items categoryquery
- the string to search forcompleted
- true if only completed media items, false if only tracked (= not completed), null if anypublic java.util.List<MediaItem> getMediaItemsReleasedToday(Category category)
category
- the media items categorypublic long getAllMediaItemsNumberInCategory(Category category)
category
- the media items categorypublic MediaItem getMediaItemById(Category category, java.lang.Long itemId)
category
- the media item categoryitemId
- the media item IDpublic MediaItem getRandomTrackedMediaItem(Category category, java.lang.Long idDifferentFromIfPossible, java.lang.String genresContains, java.lang.Boolean owned, int minDuration, int maxDuration)
category
- the media item categoryidDifferentFromIfPossible
- if possible, the retrieved media item has a different ID from this one ("if possible" means that if there's only one item that matches in the whole database, it is returned anyway). May be nullgenresContains
- genres contains this value. May be nullowned
- true if the media item is owned by the user, false if it's not owned, null if it doesn't matter (owned or not)minDuration
- min duration (e.g. pages number, runtime,...). May be <= 0 if not interested in this constraintmaxDuration
- max duration (e.g. pages number, runtime,...). May be <= 0 if not interested in this constraintpublic MediaItem getRandomCompletedMediaItem(Category category, java.lang.Long idDifferentFromIfPossible, java.lang.String genresContains, int completedYearsAgo, int minDuration, int maxDuration)
category
- the media item categoryidDifferentFromIfPossible
- if possible, the retrieved media item has a different ID from this one ("if possible" means that if there's only one item that matches in the whole database, it is returned anyway). May be nullgenresContains
- genres contains this value. May be nullcompletedYearsAgo
- completion date is at least the given amount of years ago. May be 0minDuration
- min duration (e.g. pages number, runtime,...). May be 0maxDuration
- max duration (e.g. pages number, runtime,...). May be 0public void setMediaItemAsCompleted(MediaItem mediaItem, java.util.Date completionDate)
mediaItem
- the media itemcompletionDate
- the completion datepublic void updateMediaItemCompletionDate(MediaItem mediaItem, java.util.Date completionDate)
mediaItem
- the media itemcompletionDate
- the completion datepublic void setMediaItemAsDoingNow(MediaItem mediaItem, boolean doingNow)
mediaItem
- the media itemdoingNow
- true if user is "doing" the media item nowpublic void setMediaItemAsOwned(MediaItem mediaItem, boolean owned)
mediaItem
- the media itemowned
- true if the user owns the media itempublic void undoSetAsCompleted(MediaItem mediaItem)
setMediaItemAsCompleted(MediaItem, Date)
mediaItem
- the media itempublic void setMediaItemAsToRedo(MediaItem mediaItem)
mediaItem
- the media itempublic void saveMediaItem(MediaItem mediaItem)
mediaItem
- the media item to update/insertpublic void deleteMediaItem(MediaItem mediaItem)
mediaItem
- the media item to removepublic void deleteAllMediaItemsInCategory(Category category)
category
- the categorypublic void setOrderInSectionAfterMove(Category category, MediaItem movedMediaItem, MediaItem previousMediaItemInSection, MediaItem nextMediaItemInSection)
category
- the media item categorymovedMediaItem
- the media items that has just movedpreviousMediaItemInSection
- the media item before the moved one in the sectionnextMediaItemInSection
- the media item after the moved one in the sectionpublic void setMediaItemOrderInSectionBeforeInserting(Category category, MediaItem newMediaItem)
category
- the media item categorynewMediaItem
- the media item to be insertedpublic void setMediaItemOrderInSectionBeforeUpdatingImportanceLevel(Category category, MediaItem updatedMediaItem)
setOrderInSectionAfterMove(Category, MediaItem, MediaItem, MediaItem)
category
- the media item categoryupdatedMediaItem
- the media item to be updated with a different importance levelpublic java.lang.String validateMediaItem(Context context, MediaItem mediaItem)
context
- the contextmediaItem
- the media item to validateprotected abstract java.lang.String validateSpecificMediaItem(Context context, MediaItem mediaItem)
validateMediaItem(Context, MediaItem)
public java.lang.String validateMediaItemDbRow(Context context, java.util.HashMap<java.lang.String,java.lang.Object> values)
validateMediaItem(Context, MediaItem)
but with actual DB valuescontext
- the contextvalues
- hash column name => valueprotected abstract java.lang.String validateSpecificMediaItemDbRow(Context context, java.util.HashMap<java.lang.String,java.lang.Object> values)
validateMediaItemDbRow(Context, HashMap)