Class Image

All Implemented Interfaces:
Database.Dissolvable, Database.UpdateListener

@Dissolves public class Image extends DatabaseInstance<Image>
An instance of an image database item - An image cannot be edited
  • Field Details

  • Constructor Details

  • Method Details

    • cast

      @Observes protected Image cast()
      Description copied from class: DatabaseInstance
      Gets this instance casted to the generic type
      Specified by:
      cast in class DatabaseInstance<Image>
      Returns:
      This as the generic type
    • getLocType

      public Database.Collections getLocType()
    • getFormatedLocType

      public String getFormatedLocType()
      Returns the loc type as a formatted string
    • getLocName

      public String getLocName()
    • getLocID

      public String getLocID()
    • setLocID

      public boolean setLocID(String val)
    • setLocName

      public boolean setLocName(String val)
    • setLocType

      public boolean setLocType(Database.Collections val)
    • getImageID

      public String getImageID()
    • getUploadTime

      public com.google.firebase.Timestamp getUploadTime()
    • getAddress

      public String getAddress()
    • loadAndFormatImage

      public com.squareup.picasso.RequestCreator loadAndFormatImage(Image.Options option)
      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 class DatabaseInstance<Image>
      Returns:
      A list of all querries that should be run whose instances will be deleted when this instance is deleted
    • requiredFirstDelete

      protected void requiredFirstDelete(int deletionType, Consumer<Boolean> listener)
      Description copied from class: DatabaseInstance
      Deletes any sub objects that are not instances
      Overrides:
      requiredFirstDelete in class DatabaseInstance<Image>
      Parameters:
      deletionType - The DatabaseInstance.DeletionType reason this instance is being deleted
      listener - 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 database
      locName - the Name of where the image is stored
      locType - the type of where the image is stored
      locID - the database ID of where the image is stored
      image - the image file
      listener - 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 loaded
      collection - The collection to base the default off of if the instance is null
      option - The formatting options
      resources - The resources to use for creating the drawable
      useDrawable - 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
      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 loaded
      option - The formatting options
      resources - The resources to use for creating the drawable
      useDrawable - 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
      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 loaded
      collection - The collection to base the default off of if the instance is null
      option - The formatting options
      useBitmap - Called on completion with the bitmap or null
      • If error, success = false
      • If good, success = true
      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 loaded
      option - The formatting options
      useBitmap - Called on completion with the bitmap or null
      • If error, success = false
      • If good, success = true
      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 loaded
      collection - 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 an ImageView
      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 an ImageView
      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 on
      option - 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 on
      option - 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 on
      collection - The collection to base the default on if the instance is null
      option - 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 drawable
      option - 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 drawable
      useDrawable - 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
    • 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