com.vodafone360.people.utils
Class ThumbnailUtils

java.lang.Object
  extended by com.vodafone360.people.utils.ThumbnailUtils

public final class ThumbnailUtils
extends java.lang.Object

Set of static utility functions for handling of thumb-nails within the People client. Thumb-nails are stored in a specific sub-directory ('app_np_thumbs') of the People application directory. Thumb-nail names are based on a supplied ID (local Contact ID).


Field Summary
private static java.lang.String JPG_EXTENSION
          JPEG file extension.
private static int PHOTO_QUALITY
          Thumbnail file compression quality.
static java.lang.String PNG_EXTENSION
          PNG file extension.
static java.lang.String REQUEST_THUMBNAIL_URI
          Thumbnail request URI.
static java.lang.String THUMBNAIL_FILE_LOCATION
          Full path for the thumbnails.
private static int THUMBNAIL_HEIGHT
          Height of thumb-nails stored by People client.
private static int THUMBNAIL_WIDTH
          Width of thumb-nails stored by People client.
 
Constructor Summary
private ThumbnailUtils()
          Private constructor to prevent the utility class from being instantiated.
 
Method Summary
static boolean copyAndCompressBitmap(java.lang.String destinationPath, Bitmap inputPhoto)
          Copies and compresses the given bitmap image.
private static void ensureThumbnailFolderExists()
          Checks if the thumbnail folder exists and creates it if not.
private static java.io.File makeFile(long localContactId)
          Creates a new File for the given Local Contact ID.
static void saveExternalResponseObjectToFile(long localContactId, ExternalResponseObject ext, int quality)
          Saves an image in an ExternalResponseObject to the file system.
static java.lang.String thumbnailFileToWrite(java.lang.Long thumbnailId)
          Generate filename for thumb-nail.
static Bitmap thumbnailFromFile(java.lang.Long thumbnailId)
          Return Bitmap containing thumb-nail matching the supplied ID.
static java.lang.String thumbnailPath(java.lang.Long thumbnailId)
          Return path to file containing specified thumb-nail.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THUMBNAIL_FILE_LOCATION

public static final java.lang.String THUMBNAIL_FILE_LOCATION
Full path for the thumbnails.

See Also:
Constant Field Values

JPG_EXTENSION

private static final java.lang.String JPG_EXTENSION
JPEG file extension.

See Also:
Constant Field Values

PNG_EXTENSION

public static final java.lang.String PNG_EXTENSION
PNG file extension.

See Also:
Constant Field Values

REQUEST_THUMBNAIL_URI

public static final java.lang.String REQUEST_THUMBNAIL_URI
Thumbnail request URI.

See Also:
Constant Field Values

PHOTO_QUALITY

private static final int PHOTO_QUALITY
Thumbnail file compression quality.

See Also:
Constant Field Values

THUMBNAIL_HEIGHT

private static final int THUMBNAIL_HEIGHT
Height of thumb-nails stored by People client.

See Also:
Constant Field Values

THUMBNAIL_WIDTH

private static final int THUMBNAIL_WIDTH
Width of thumb-nails stored by People client.

See Also:
Constant Field Values
Constructor Detail

ThumbnailUtils

private ThumbnailUtils()
Private constructor to prevent the utility class from being instantiated.

Method Detail

thumbnailPath

public static java.lang.String thumbnailPath(java.lang.Long thumbnailId)
Return path to file containing specified thumb-nail.

Parameters:
thumbnailId - ID of thumb-nail.
Returns:
path to thumb-nail file, NULL if it does not exist.

thumbnailFileToWrite

public static java.lang.String thumbnailFileToWrite(java.lang.Long thumbnailId)
Generate filename for thumb-nail. This consists of the thumb-nail ID and the .JPG extension.

Parameters:
thumbnailId - ID of thumb-nail (e.g. local Contact ID).
Returns:
String containing generated filename.

thumbnailFromFile

public static Bitmap thumbnailFromFile(java.lang.Long thumbnailId)
Return Bitmap containing thumb-nail matching the supplied ID. A 50 x 50 Bitmap is generated if a file for the specified ID exists.

Parameters:
thumbnailId - ID of thumb-nail to retrieve.
Returns:
Bitmap of the requested thumb-nail, NULL if Bitmap cannot be generated.

ensureThumbnailFolderExists

private static void ensureThumbnailFolderExists()
Checks if the thumbnail folder exists and creates it if not.


copyAndCompressBitmap

public static boolean copyAndCompressBitmap(java.lang.String destinationPath,
                                            Bitmap inputPhoto)
                                     throws java.io.IOException
Copies and compresses the given bitmap image.

Parameters:
destinationPath - Path to save new image.
inputPhoto - Input Bitmap to save.
Returns:
TRUE if the photo was successfully saved, FALSE if otherwise.
Throws:
java.io.IOException - Issue with photoPath in the file system.
java.io.FileNotFoundException - Issue with photoPath in the file system.
java.security.InvalidParameterException - destinationPath is empty.
java.security.InvalidParameterException - inputPhoto is NULL.

saveExternalResponseObjectToFile

public static void saveExternalResponseObjectToFile(long localContactId,
                                                    ExternalResponseObject ext,
                                                    int quality)
                                             throws java.io.IOException
Saves an image in an ExternalResponseObject to the file system.

Parameters:
localContactId - Local contact ID if the new Thumbnail files.
ext - Given ExternalResponseObject to convert.
quality - Compression quality of saved image.
Throws:
java.io.IOException - File system issues.

makeFile

private static java.io.File makeFile(long localContactId)
                              throws java.io.IOException
Creates a new File for the given Local Contact ID.

Parameters:
localContactId - Local contact ID if the new Thumbnail files.
Returns:
Newly created file.
Throws:
java.io.IOException - File system issue.
java.security.InvalidParameterException - localContactId must be above 0.


JavaDoc