ProfilePictureView
เวอร์ชั่นที่ใหม่กว่าของคลาสนี้พร้อมแล้ว ตรวจสอบได้ เวอร์ชั่นล่าสุด

View that displays the profile photo of a supplied profile ID, while conforming to user specified dimensions.

ขยาย:FrameLayout
แพ็คเกจ:widget
ผู้สร้าง
ProfilePictureView(Context)

Constructor

public ProfilePictureView(Context context)
พารามิเตอร์คำอธิบาย
contextContext for this View
ProfilePictureView(Context, AttributeSet)

Constructor

public ProfilePictureView(Context context, AttributeSet attrs)
พารามิเตอร์คำอธิบาย
contextContext for this View
attrsAttributeSet for this View. The attribute 'preset_size' is processed here
ProfilePictureView(Context, AttributeSet, int)

Constructor

public ProfilePictureView(Context context, AttributeSet attrs, int defStyle)
พารามิเตอร์คำอธิบาย
contextContext for this View
attrsAttributeSet for this View. The attribute 'preset_size' is processed here
defStyleDefault style for this View
วิธีการแบบอินสแตนซ์
getPresetSize()

Gets the current preset size type

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

Apply a preset size to this profile photo

public final void setPresetSize(int sizeType)
พารามิเตอร์คำอธิบาย
sizeTypeThe size type to apply: SMALL, NORMAL or LARGE
isCropped()

Indicates whether the cropped version of the profile photo has been chosen

public final boolean isCropped()
Returns
True if the cropped version is chosen, false if not.
setCropped(boolean)

Sets the profile photo to be the cropped version, or the original version

public final void setCropped(boolean showCroppedVersion)
พารามิเตอร์คำอธิบาย
showCroppedVersionTrue to select the cropped version False to select the standard version
getProfileId()

Returns the profile Id for the current profile photo

public final String getProfileId()
Returns
The profile Id
setProfileId(String)

Sets the profile Id for this profile photo

public final void setProfileId(String profileId)
พารามิเตอร์คำอธิบาย
profileIdThe profileId NULL/Empty String will show the blank profile photo
getOnErrorListener()

Returns the current OnErrorListener for this instance of ProfilePictureView

public final OnErrorListener getOnErrorListener()
Returns
The OnErrorListener
setOnErrorListener(OnErrorListener)

Sets an OnErrorListener for this instance of ProfilePictureView to call into when certain exceptions occur.

public final void setOnErrorListener(OnErrorListener onErrorListener)
พารามิเตอร์คำอธิบาย
onErrorListenerThe Listener object to set
setDefaultProfilePicture(Bitmap)

The ProfilePictureView will display the provided image while the specified profile is being loaded, or if the specified profile is not available.

public final void setDefaultProfilePicture(Bitmap inputBitmap)
พารามิเตอร์คำอธิบาย
inputBitmapThe bitmap to render until the actual profile is loaded.
onMeasure(int, int)

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

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
พารามิเตอร์คำอธิบาย
widthMeasureSpec
heightMeasureSpec
onLayout(boolean, int, int, int, int)

In addition to calling super.Layout(), we also attempt to get a new image that is properly size for the layout dimensions

protected void onLayout(boolean changed, int left, int top, int right, int bottom)
พารามิเตอร์คำอธิบาย
changed
left
top
right
bottom
onSaveInstanceState()

Some of the current state is returned as a Bundle to allow quick restoration of the ProfilePictureView object in scenarios like orientation changes.

protected Parcelable onSaveInstanceState()
Returns
A Parcelable containing the current state
onRestoreInstanceState(Parcelable)

If the passed in state is a Bundle, an attempt is made to restore from it.

protected void onRestoreInstanceState(Parcelable state)
พารามิเตอร์คำอธิบาย
stateA Parcelable containing the current state
onDetachedFromWindow()
protected void onDetachedFromWindow()
ค่าคงตัว
TAG
Tag used when logging calls are made by ProfilePictureView
public static final String TAG
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.
public static final int CUSTOM
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.
public static final int SMALL
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.
public static final int NORMAL
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.
public static final int LARGE