Package com.syzygy.events.database
Class Image
- All Implemented Interfaces:
Database.Dissolvable
,Database.UpdateListener
An instance of an image database item
- An image cannot be edited
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Crops the image to the largest circle that fits within.static class
Auto generates an avatar with initialsstatic class
Nested classes/interfaces inherited from class com.syzygy.events.database.DatabaseInstance
DatabaseInstance.DeletionType, DatabaseInstance.InstancePropertyWrapper<W extends DatabaseInstance<W>>, DatabaseInstance.PropertyField<V,
W extends DatabaseInstance<W>>, DatabaseInstance.PropertyWrapper<V, W extends DatabaseInstance<W>> Nested classes/interfaces inherited from interface com.syzygy.events.database.Database.UpdateListener
Database.UpdateListener.Type
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final DatabaseInstance.PropertyField<?,
?>[] The list of the fields defined for a UserFields inherited from class com.syzygy.events.database.DatabaseInstance
db, iproperties, properties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Image
cast()
Gets this instance casted to the generic typestatic com.squareup.picasso.RequestCreator
formatDefaultImage
(Database.Collections collection, Image.Options option) Formats a default image based on the collectionstatic com.squareup.picasso.RequestCreator
formatDefaultImage
(DatabaseInstance<?> instance, Database.Collections collection, Image.Options option) Formats a default image based on the instancestatic com.squareup.picasso.RequestCreator
formatDefaultImage
(DatabaseInstance<?> instance, Image.Options option) Formats a default image based on the instancestatic com.squareup.picasso.RequestCreator
formatImage
(int resID, Image.Options option) Formats the drawablestatic com.squareup.picasso.RequestCreator
formatImage
(com.squareup.picasso.RequestCreator loadedPicasso, Image.Options option) Formats the loaded image based on the collectionstatic com.squareup.picasso.RequestCreator
getDefaultImage
(Database.Collections collection) Gets and loads a default image for the collectionstatic com.squareup.picasso.RequestCreator
getDefaultImage
(DatabaseInstance<?> instance) Gets and loads a default image for the instancestatic com.squareup.picasso.RequestCreator
getFormatedAssociatedImage
(DatabaseInstance<?> instance, Database.Collections collection, Image.Options option) Loads the associated image of the instance and formats it.static com.squareup.picasso.RequestCreator
getFormatedAssociatedImage
(DatabaseInstance<?> instance, Image.Options option) Loads the associated image of the instance and formats it.static void
getFormatedAssociatedImageAsBitmap
(DatabaseInstance<?> instance, Database.Collections collection, Image.Options option, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Loads the associated image of the instance and formats it.static void
getFormatedAssociatedImageAsBitmap
(DatabaseInstance<?> instance, Image.Options option, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Loads the associated image of the instance and formats it.static void
getFormatedAssociatedImageAsDrawable
(DatabaseInstance<?> instance, Database.Collections collection, Image.Options option, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Loads the associated image of the instance and formats it.static void
getFormatedAssociatedImageAsDrawable
(DatabaseInstance<?> instance, Image.Options option, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Loads the associated image of the instance and formats it.Returns the loc type as a formatted stringgetLocID()
com.google.firebase.Timestamp
com.squareup.picasso.RequestCreator
loadAndFormatImage
(Image.Options option) Loads the image into a picasso request and formats it based on the collection typestatic void
loadAsBitmap
(com.squareup.picasso.RequestCreator loadedPicasso, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Turns a loaded picasso into a bitmapstatic void
loadAsDrawable
(com.squareup.picasso.RequestCreator loadedPicasso, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Turns a loaded picasso into a drawableNewInstance
(Database db, String locName, Database.Collections locType, String locID, android.net.Uri image, Database.InitializationListener<Image> listener) Validates and creates a new Image instance in the database using the given data.protected void
requiredFirstDelete
(int deletionType, Consumer<Boolean> listener) Deletes any sub objects that are not instancesboolean
boolean
setLocName
(String val) boolean
protected List<android.util.Pair<com.google.firebase.firestore.Query,
Database.Collections>> Methods inherited from class com.syzygy.events.database.DatabaseInstance
addInitializationListener, addListener, assertNotIllegalState, deleteInstance, dereferenceInstance, dissolve, dissolve, doesPropertyLoadInstance, fetch, fetch, fullDissolve, getAssociatedImage, getAssociatedImageLocName, getCollection, getCollectionReference, getData, getDatabaseID, getDocumentID, getDocumentReference, getFields, getPropertyInstance, getPropertyInstanceI, getPropertyValue, getPropertyValueI, initializeData, isDataValid, isDataValid, isLegalState, isPropertyEditable, isPropertyValid, isPropertyValid, isReferenced, modifyData, notifyUpdate, onUpdate, processUpdate, removeListener, setAssociatedImage, setPropertyInstance, setPropertyValue, subDereferenceInstance, subInitialize, toString, updateDataFromDatabase, updateDataFromMap, updateDataFromMap
-
Field Details
-
fields
The list of the fields defined for a User
-
-
Constructor Details
-
Image
Checks to make sure the generic type is the type of this instance- Parameters:
db
- The databaseimageID
- The id of the image- Throws:
ClassCastException
-
-
Method Details
-
cast
Description copied from class:DatabaseInstance
Gets this instance casted to the generic type- Specified by:
cast
in classDatabaseInstance<Image>
- Returns:
- This as the generic type
-
getLocType
-
getFormatedLocType
Returns the loc type as a formatted string -
getLocName
-
getLocID
-
setLocID
-
setLocName
-
setLocType
-
getImageID
-
getUploadTime
public com.google.firebase.Timestamp getUploadTime() -
getAddress
-
loadAndFormatImage
Loads the image into a picasso request and formats it based on the collection type- Parameters:
option
- How to format the image- Returns:
- The picasso creator with this image formated
- See Also:
-
subInstanceCascadeDeleteQuery
protected List<android.util.Pair<com.google.firebase.firestore.Query,Database.Collections>> subInstanceCascadeDeleteQuery()- Specified by:
subInstanceCascadeDeleteQuery
in classDatabaseInstance<Image>
- Returns:
- A list of all querries that should be run whose instances will be deleted when this instance is deleted
-
requiredFirstDelete
Description copied from class:DatabaseInstance
Deletes any sub objects that are not instances- Overrides:
requiredFirstDelete
in classDatabaseInstance<Image>
- Parameters:
deletionType
- TheDatabaseInstance.DeletionType
reason this instance is being deletedlistener
- Called before the instance and sub instances are deleted; they are only deleted if this returns true
-
NewInstance
@MustStir public static Set<Integer> NewInstance(Database db, String locName, Database.Collections locType, String locID, @NonNull android.net.Uri image, Database.InitializationListener<Image> listener) Validates and creates a new Image instance in the database using the given data.- Parameters:
db
- The databaselocName
- the Name of where the image is storedlocType
- the type of where the image is storedlocID
- the database ID of where the image is storedimage
- the image filelistener
- This will be called once the image is initialized. Is not called if the data is invalid- Returns:
- The property id of all invalid properties
- See Also:
-
getFormatedAssociatedImageAsDrawable
public static void getFormatedAssociatedImageAsDrawable(@Nullable @Observes DatabaseInstance<?> instance, Database.Collections collection, Image.Options option, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loadedcollection
- The collection to base the default off of if the instance is nulloption
- The formatting optionsresources
- The resources to use for creating the drawableuseDrawable
- Called on preparation with a placeHolder drawable, then again on completion of load with the drawable or an error drawable if failed.- If placeholder,
success = null
- If error,
success = false
- If good,
success = true
- If placeholder,
- See Also:
-
getFormatedAssociatedImageAsDrawable
public static void getFormatedAssociatedImageAsDrawable(@NonNull @Observes DatabaseInstance<?> instance, Image.Options option, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loadedoption
- The formatting optionsresources
- The resources to use for creating the drawableuseDrawable
- Called on preparation with a placeHolder drawable, then again on completion of load with the drawable or an error drawable if failed.- If placeholder,
success = null
- If error,
success = false
- If good,
success = true
- If placeholder,
- See Also:
-
getFormatedAssociatedImageAsBitmap
public static void getFormatedAssociatedImageAsBitmap(@Nullable @Observes DatabaseInstance<?> instance, Database.Collections collection, Image.Options option, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loadedcollection
- The collection to base the default off of if the instance is nulloption
- The formatting optionsuseBitmap
- Called on completion with the bitmap or null- If error,
success = false
- If good,
success = true
- If error,
- See Also:
-
getFormatedAssociatedImageAsBitmap
public static void getFormatedAssociatedImageAsBitmap(@NonNull @Observes DatabaseInstance<?> instance, Image.Options option, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loadedoption
- The formatting optionsuseBitmap
- Called on completion with the bitmap or null- If error,
success = false
- If good,
success = true
- If error,
- See Also:
-
getFormatedAssociatedImage
public static com.squareup.picasso.RequestCreator getFormatedAssociatedImage(@Nullable @Observes DatabaseInstance<?> instance, Database.Collections collection, Image.Options option) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loadedcollection
- The collection to base the default off of if the instance is null- Returns:
- The loaded and formatted image. Uses
.into(view)
to load the image to anImageView
- See Also:
-
getFormatedAssociatedImage
public static com.squareup.picasso.RequestCreator getFormatedAssociatedImage(@NonNull @Observes DatabaseInstance<?> instance, Image.Options option) Loads the associated image of the instance and formats it. If the instance is null, uses a default image. If the associated image is null, uses a default image for the instances collection.- Parameters:
instance
- The instance whos image should be loaded- Returns:
- The loaded and formatted image. Uses
.into(view)
to load the image to anImageView
- See Also:
-
getDefaultImage
public static com.squareup.picasso.RequestCreator getDefaultImage(@NonNull DatabaseInstance<?> instance) Gets and loads a default image for the instance- Parameters:
instance
- The instance that the image is for- Returns:
- The loaded request creator for the image
- See Also:
-
getDefaultImage
public static com.squareup.picasso.RequestCreator getDefaultImage(@NonNull Database.Collections collection) Gets and loads a default image for the collection- Parameters:
collection
- The collection that the image is for- Returns:
- The loaded request creator for the image
-
formatDefaultImage
public static com.squareup.picasso.RequestCreator formatDefaultImage(@NonNull Database.Collections collection, @NonNull Image.Options option) Formats a default image based on the collection- Parameters:
collection
- The collection to base the default onoption
- How to format the image- Returns:
- The loaded picasso after formatting
- See Also:
-
formatDefaultImage
public static com.squareup.picasso.RequestCreator formatDefaultImage(@NonNull DatabaseInstance<?> instance, @NonNull Image.Options option) Formats a default image based on the instance- Parameters:
instance
- The instance to base the default onoption
- How to format the image- Returns:
- The loaded picasso after formatting
- See Also:
-
formatDefaultImage
public static com.squareup.picasso.RequestCreator formatDefaultImage(@Nullable DatabaseInstance<?> instance, @NonNull Database.Collections collection, @NonNull Image.Options option) Formats a default image based on the instance- Parameters:
instance
- The instance to base the default oncollection
- The collection to base the default on if the instance is nulloption
- How to format the image- Returns:
- The loaded picasso after formatting
- See Also:
-
formatImage
public static com.squareup.picasso.RequestCreator formatImage(@DrawableRes int resID, @NonNull Image.Options option) Formats the drawable- Parameters:
resID
- the id of the drawableoption
- How to format the image- Returns:
- The loaded picasso after formatting
-
formatImage
public static com.squareup.picasso.RequestCreator formatImage(@NonNull com.squareup.picasso.RequestCreator loadedPicasso, @NonNull Image.Options option) Formats the loaded image based on the collection- Parameters:
loadedPicasso
- The picasso element that is loaded with the image.option
- How to format the image- Returns:
- The loaded picasso after formatting
-
loadAsDrawable
public static void loadAsDrawable(@NonNull com.squareup.picasso.RequestCreator loadedPicasso, android.content.res.Resources resources, BiConsumer<Boolean, android.graphics.drawable.Drawable> useDrawable) Turns a loaded picasso into a drawable- Parameters:
loadedPicasso
- The picasso element that is loaded with the image.resources
- The resources to use for creating the drawableuseDrawable
- Called on preparation with a placeHolder drawable, then again on completion of load with the drawable or an error drawable if failed.- If placeholder,
success = null
- If error,
success = false
- If good,
success = true
- If placeholder,
-
loadAsBitmap
public static void loadAsBitmap(@NonNull com.squareup.picasso.RequestCreator loadedPicasso, BiConsumer<Boolean, android.graphics.Bitmap> useBitmap) Turns a loaded picasso into a bitmap- Parameters:
loadedPicasso
- The picasso element that is loaded with the image.useBitmap
- Called on completion with the bitmap or null- If error,
success = false
- If good,
success = true
- If error,
-