Reference Source
public class | source

ImageUtility

You can directly use an instance of this class. ImageUtil

Image utility class for helping with image handling.

Method Summary

Public Methods
public

addRemainingDefaults(type: string, thumbnails: List): List

Add remaining defaults to the list of thumbnails for editing purposes.

public

checkImageListValid(imagelist: List): Boolean

Checks whether the image list is valid using an overly complex set of logical comparisons.

public

checkNumDefaults(type: string, num_defaults: Number, uploaded_images: List): Boolean

Checks the number of defaults with the length of the uploaded images and the allowed number of images.

public

checkPhotosForDefaults(type: string, images: List): Boolean

Checks if all the images are default images.

public

formThumbnail(thumbnails: List): List

Forms the thumbnail into a useable list of objects.

public

Returns the default image for a specific image type.

public

getDefaultPhotos(type: string): List

Return the default photo entries.

public

Returns the defined file extension for images.

public

Returns the photo entries.

public

getTypeConstant(type: string, index: Number): string/Number

Returns the constant associated with a particular image type and index.

public

Returns the possible image types.

public

Checks if an image has already been uploaded by checking if it contains the firebase url.

public

Checks if the image is the default image for an associated type.

Public Methods

public addRemainingDefaults(type: string, thumbnails: List): List source

Add remaining defaults to the list of thumbnails for editing purposes.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

thumbnails List

A list of thumbnails

Return:

List

A list of thumbnails of length NUMBER_OF_BIKE_IMAGES with defaults

public checkImageListValid(imagelist: List): Boolean source

Checks whether the image list is valid using an overly complex set of logical comparisons. Really not needed but all these cases came up and proved to be a problem.

Params:

NameTypeAttributeDescription
imagelist List

A list of images to check

Return:

Boolean

true: If valid; false: otherwise

public checkNumDefaults(type: string, num_defaults: Number, uploaded_images: List): Boolean source

Checks the number of defaults with the length of the uploaded images and the allowed number of images.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

num_defaults Number

The number of defaults found

uploaded_images List

The list of uploaded images

Return:

Boolean

true: If the number of defaults found is conversely related to the number of uploaded images based on the allowed number of images; false: otherwise

public checkPhotosForDefaults(type: string, images: List): Boolean source

Checks if all the images are default images.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

images List

A list of images

Return:

Boolean

true: if all the images are the default image; false: if any one of them is not

public formThumbnail(thumbnails: List): List source

Forms the thumbnail into a useable list of objects.

Params:

NameTypeAttributeDescription
thumbnails List

A list of thumbnails with links

Return:

List

A list of thumbnail objects with an 'illustration' property

public getDefaultImage(type: string): string source

Returns the default image for a specific image type.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

Return:

string

The default image for the image type

public getDefaultPhotos(type: string): List source

Return the default photo entries.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

Return:

List

A list of objects with the property 'illustration' that contains the uri

public getFileExtension(): string source

Returns the defined file extension for images.

Return:

string

The file extension (default '.jpg')

public getPhotoEntries(type: string): Object source

Returns the photo entries.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

Return:

Object

The photo entries

public getTypeConstant(type: string, index: Number): string/Number source

Returns the constant associated with a particular image type and index.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

index Number

The index of the constant in TYPE_CONSTANTS

Return:

string/Number

The constant associated with the type and index

public getTypes(): Object source

Returns the possible image types.

Return:

Object

An object of strings

public isAlreadyUploaded(image: string): Boolean source

Checks if an image has already been uploaded by checking if it contains the firebase url.

Params:

NameTypeAttributeDescription
image string

An image url to check. Might be an object if image is trying to be uploaded

Return:

Boolean

true: If the image has already been uploaded; false: otherwise

public isDefaultImage(type: string, image: string): Boolean source

Checks if the image is the default image for an associated type.

Params:

NameTypeAttributeDescription
type string

The type of image constant requested (e.g. BIKE, PROFILE, etc.)

image string

The url to an image

Return:

Boolean

true: if the image is the default image; false: otherwise