Android SDK Version
  • java.lang.Object
    • FrameLayout
      • com.facebook.login.widget.ProfilePictureView

public class ProfilePictureView
extends FrameLayout
View that displays the profile photo of a supplied profile ID, while conforming to user specified dimensions.
Nested Class Summary
Modifier and TypeClass and Description
static interface ProfilePictureView.OnErrorListener
Callback interface that will be called when a network or other error is encountered while retrieving profile pictures.
Field Summary
Modifier and TypeField and Description
static intCUSTOM
Indicates that the specific size of the View will be set via layout params.
static intLARGE
Indicates that the profile image should fit in a LARGE X LARGE space, regardless of whether the cropped or un-cropped version is chosen.
static intNORMAL
Indicates that the profile image should fit in a NORMAL X NORMAL space, regardless of whether the cropped or un-cropped version is chosen.
static intSMALL
Indicates that the profile image should fit in a SMALL X SMALL space, regardless of whether the cropped or un-cropped version is chosen.
static java.lang.StringTAG
Tag used when logging calls are made by ProfilePictureView
Constructor Summary
Constructor and Description
ProfilePictureView(Context context)
Constructor
ProfilePictureView(Context context, AttributeSet attrs)
Constructor
ProfilePictureView(Context context, AttributeSet attrs, int defStyle)
Constructor
Method Summary
Modifier and TypeMethod and Description
ProfilePictureView.OnErrorListenergetOnErrorListener()
Returns the current OnErrorListener for this instance of ProfilePictureView
intgetPresetSize()
Gets the current preset size type
java.lang.StringgetProfileId()
Returns the profile Id for the current profile photo
booleanisCropped()
Indicates whether the cropped version of the profile photo has been chosen
protected voidonDetachedFromWindow() 
protected voidonLayout(boolean changed, int left, int top, int right, int bottom)
In addition to calling super.Layout(), we also attempt to get a new image that is properly sized for the layout dimensions
protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)
Overriding onMeasure to handle the case where WRAP_CONTENT might be specified in the layout.
protected voidonRestoreInstanceState(Parcelable state)
If the passed in state is a Bundle, an attempt is made to restore from it.
protected ParcelableonSaveInstanceState()
Some of the current state is returned as a Bundle to allow quick restoration of the ProfilePictureView object in scenarios like orientation changes.
voidsetCropped(boolean showCroppedVersion)
Sets the profile photo to be the cropped version, or the original version
voidsetDefaultProfilePicture(Bitmap inputBitmap)
The ProfilePictureView will display the provided image while the specified profile is being loaded, or if the specified profile is not available.
voidsetOnErrorListener(ProfilePictureView.OnErrorListener onErrorListener)
Sets an OnErrorListener for this instance of ProfilePictureView to call into when certain errors occur.
voidsetPresetSize(int sizeType)
Apply a preset size to this profile photo
voidsetProfileId(java.lang.String profileId)
Sets the profile Id for this profile photo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail

TAG

public static final java.lang.String TAG
Tag used when logging calls are made by ProfilePictureView

CUSTOM

public static final int CUSTOM
Indicates that the specific size of the View will be set via layout params. ProfilePictureView will default to NORMAL X NORMAL, if the layout params set on this instance do not have a fixed size. Used in calls to setPresetSize() and getPresetSize(). Corresponds with the preset_size Xml attribute that can be set on ProfilePictureView.

SMALL

public static final int SMALL
Indicates that the profile image should fit in a SMALL X SMALL space, regardless of whether the cropped or un-cropped version is chosen. Used in calls to setPresetSize() and getPresetSize(). Corresponds with the preset_size Xml attribute that can be set on ProfilePictureView.

NORMAL

public static final int NORMAL
Indicates that the profile image should fit in a NORMAL X NORMAL space, regardless of whether the cropped or un-cropped version is chosen. Used in calls to setPresetSize() and getPresetSize(). Corresponds with the preset_size Xml attribute that can be set on ProfilePictureView.

LARGE

public static final int LARGE
Indicates that the profile image should fit in a LARGE X LARGE space, regardless of whether the cropped or un-cropped version is chosen. Used in calls to setPresetSize() and getPresetSize(). Corresponds with the preset_size Xml attribute that can be set on ProfilePictureView.
Constructor Detail

ProfilePictureView

public ProfilePictureView(Context context)
Constructor
Parameters:
context - Context for this View

ProfilePictureView

public ProfilePictureView(Context context,
                          AttributeSet attrs)
Constructor
Parameters:
context - Context for this View
attrs - AttributeSet for this View. The attribute 'preset_size' is processed here

ProfilePictureView

public ProfilePictureView(Context context,
                          AttributeSet attrs,
                          int defStyle)
Constructor
Parameters:
context - Context for this View
attrs - AttributeSet for this View. The attribute 'preset_size' is processed here
defStyle - Default style for this View
Method Detail

getPresetSize

public final int getPresetSize()
Gets the current preset size type
Returns:
The current preset size type, if set; CUSTOM if not

setPresetSize

public final void setPresetSize(int sizeType)
Apply a preset size to this profile photo
Parameters:
sizeType - The size type to apply: SMALL, NORMAL or LARGE

isCropped

public final boolean isCropped()
Indicates whether the cropped version of the profile photo has been chosen
Returns:
True if the cropped version is chosen, false if not.

setCropped

public final void setCropped(boolean showCroppedVersion)
Sets the profile photo to be the cropped version, or the original version
Parameters:
showCroppedVersion - True to select the cropped version False to select the standard version

getProfileId

public final java.lang.String getProfileId()
Returns the profile Id for the current profile photo
Returns:
The profile Id

setProfileId

public final void setProfileId(java.lang.String profileId)
Sets the profile Id for this profile photo
Parameters:
profileId - The profileId NULL/Empty String will show the blank profile photo

getOnErrorListener

public final ProfilePictureView.OnErrorListener getOnErrorListener()
Returns the current OnErrorListener for this instance of ProfilePictureView
Returns:
The OnErrorListener

setOnErrorListener

public final void setOnErrorListener(ProfilePictureView.OnErrorListener onErrorListener)
Sets an OnErrorListener for this instance of ProfilePictureView to call into when certain errors occur.
Parameters:
onErrorListener - The Listener object to set

setDefaultProfilePicture

public final void setDefaultProfilePicture(Bitmap inputBitmap)
The ProfilePictureView will display the provided image while the specified profile is being loaded, or if the specified profile is not available.
Parameters:
inputBitmap - The bitmap to render until the actual profile is loaded.

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Overriding onMeasure to handle the case where WRAP_CONTENT might be specified in the layout. Since we don't know the dimensions of the profile photo, we need to handle this case specifically.
The approach is to default to a NORMAL sized amount of space in the case that a preset size is not specified. This logic is applied to both width and height

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)
In addition to calling super.Layout(), we also attempt to get a new image that is properly sized for the layout dimensions

onSaveInstanceState

protected Parcelable onSaveInstanceState()
Some of the current state is returned as a Bundle to allow quick restoration of the ProfilePictureView object in scenarios like orientation changes.
Returns:
a Parcelable containing the current state

onRestoreInstanceState

protected void onRestoreInstanceState(Parcelable state)
If the passed in state is a Bundle, an attempt is made to restore from it.
Parameters:
state - a Parcelable containing the current state

onDetachedFromWindow

protected void onDetachedFromWindow()