public class CategoriesController
extends java.lang.Object
Constructor and Description |
---|
CategoriesController() |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultCategoriesIfEmpty(Context context)
If the categories table is empty, adds the default categories (i.e.
|
void |
deleteCategory(Category category)
Removes a category from the database (together with all media items associated to it)
|
java.util.Iterator<Category> |
getAllCategories()
Getter
|
Category |
getCategoryById(java.lang.Long categoryId)
Getter
|
static CategoriesController |
getInstance()
Singleton pattern
|
void |
saveCategory(Category category)
Inserts or updates a category in the database
|
java.lang.String |
validateCategory(Context context,
Category category)
Validates a category, possibly fixing what is wrong or, if impossible, returning an error string
|
java.lang.String |
validateCategoryDbRow(Context context,
java.util.HashMap<java.lang.String,java.lang.Object> values)
Like
validateCategory(Context, Category) but with actual DB values |
public static CategoriesController getInstance()
public java.util.Iterator<Category> getAllCategories()
public Category getCategoryById(java.lang.Long categoryId)
categoryId
- the ID of the categorypublic void addDefaultCategoriesIfEmpty(Context context)
context
- the contextpublic void saveCategory(Category category)
category
- the category to update/insertpublic void deleteCategory(Category category)
category
- the category to removepublic java.lang.String validateCategory(Context context, Category category)
context
- the contextcategory
- the category to validatepublic java.lang.String validateCategoryDbRow(Context context, java.util.HashMap<java.lang.String,java.lang.Object> values)
validateCategory(Context, Category)
but with actual DB valuescontext
- the contextvalues
- hash column name => value