Icon
class Icon : Parcelable
kotlin.Any | |
↳ | android.graphics.drawable.Icon |
An umbrella container for several serializable graphics representations, including Bitmaps, compressed bitmap images (e.g. JPG or PNG), and drawable resources (including vectors). Much ink has been spilled on the best way to load images, and many clients may have different needs when it comes to threading and fetching. This class is therefore focused on encapsulation rather than behavior.
Summary
Nested classes | |
---|---|
abstract |
Implement this interface to receive a callback when |
Constants | |
---|---|
static Int |
An icon that was created using |
static Int |
An icon that was created using |
static Int |
An icon that was created using |
static Int |
An icon that was created using android. |
static Int |
An icon that was created using android. |
static Int |
An icon that was created using android. |
Inherited constants | |
---|---|
Public methods | |
---|---|
static Icon |
createWithAdaptiveBitmap(bits: Bitmap!) Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by |
static Icon |
Create an Icon pointing to an image file specified by URI. |
static Icon |
Create an Icon pointing to an image file specified by URI. |
static Icon |
createWithBitmap(bits: Bitmap!) Create an Icon pointing to a bitmap in memory. |
static Icon |
createWithContentUri(uri: String!) Create an Icon pointing to an image file specified by URI. |
static Icon |
createWithContentUri(uri: Uri!) Create an Icon pointing to an image file specified by URI. |
static Icon |
createWithData(data: ByteArray!, offset: Int, length: Int) Create an Icon pointing to a compressed bitmap stored in a byte array. |
static Icon |
createWithFilePath(path: String!) Create an Icon pointing to an image file specified by path. |
static Icon |
createWithResource(context: Context!, resId: Int) Create an Icon pointing to a drawable resource. |
static Icon |
createWithResource(resPackage: String!, resId: Int) Create an Icon pointing to a drawable resource. |
Int |
Parcelable interface |
Int |
getResId() Gets the resource used to create this icon. |
String |
Gets the package used to create this icon. |
Int |
getType() Gets the type of the icon provided. |
Uri |
getUri() Gets the uri used to create this icon. |
Drawable? |
loadDrawable(context: Context!) Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary. |
Unit |
loadDrawableAsync(context: Context, andThen: Message) Invokes |
Unit |
loadDrawableAsync(context: Context, listener: Icon.OnDrawableLoadedListener!, handler: Handler!) Invokes |
Icon |
Store a color to use whenever this Icon is drawn. |
Icon |
setTintBlendMode(mode: BlendMode) Store a blending mode to use whenever this Icon is drawn. |
Icon |
setTintList(tintList: ColorStateList!) Store a color to use whenever this Icon is drawn. |
Icon |
setTintMode(mode: PorterDuff.Mode) Store a blending mode to use whenever this Icon is drawn. |
String |
toString() |
Unit |
writeToParcel(dest: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<Icon!> |
Constants
TYPE_ADAPTIVE_BITMAP
static val TYPE_ADAPTIVE_BITMAP: Int
An icon that was created using Icon#createWithAdaptiveBitmap
.
Value: 5
See Also
TYPE_BITMAP
static val TYPE_BITMAP: Int
An icon that was created using Icon#createWithBitmap(Bitmap)
.
Value: 1
See Also
TYPE_DATA
static val TYPE_DATA: Int
An icon that was created using Icon#createWithData(byte[], int, int)
.
Value: 3
See Also
TYPE_RESOURCE
static val TYPE_RESOURCE: Int
An icon that was created using android.graphics.drawable.Icon#createWithResource.
Value: 2
See Also
TYPE_URI
static val TYPE_URI: Int
An icon that was created using android.graphics.drawable.Icon#createWithContentUri or Icon#createWithFilePath(String)
.
Value: 4
See Also
TYPE_URI_ADAPTIVE_BITMAP
static val TYPE_URI_ADAPTIVE_BITMAP: Int
An icon that was created using android.graphics.drawable.Icon#createWithAdaptiveBitmapContentUri.
Value: 6
See Also
Public methods
createWithAdaptiveBitmap
static fun createWithAdaptiveBitmap(bits: Bitmap!): Icon
Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by AdaptiveIconDrawable
.
Parameters | |
---|---|
bits |
Bitmap!: A valid android.graphics.Bitmap object |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithAdaptiveBitmapContentUri
static fun createWithAdaptiveBitmapContentUri(uri: String): Icon
Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by AdaptiveIconDrawable
.
Parameters | |
---|---|
uri |
String: A uri referring to local content:// or file:// image data. This value cannot be null . |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithAdaptiveBitmapContentUri
static fun createWithAdaptiveBitmapContentUri(uri: Uri): Icon
Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by AdaptiveIconDrawable
.
Parameters | |
---|---|
uri |
Uri: A uri referring to local content:// or file:// image data. This value cannot be null . |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithBitmap
static fun createWithBitmap(bits: Bitmap!): Icon
Create an Icon pointing to a bitmap in memory.
Parameters | |
---|---|
bits |
Bitmap!: A valid android.graphics.Bitmap object |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithContentUri
static fun createWithContentUri(uri: String!): Icon
Create an Icon pointing to an image file specified by URI.
Parameters | |
---|---|
uri |
String!: A uri referring to local content:// or file:// image data. |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithContentUri
static fun createWithContentUri(uri: Uri!): Icon
Create an Icon pointing to an image file specified by URI.
Parameters | |
---|---|
uri |
Uri!: A uri referring to local content:// or file:// image data. |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithData
static fun createWithData(
data: ByteArray!,
offset: Int,
length: Int
): Icon
Create an Icon pointing to a compressed bitmap stored in a byte array.
Parameters | |
---|---|
data |
ByteArray!: Byte array storing compressed bitmap data of a type that android.graphics.BitmapFactory can decode (see android.graphics.Bitmap.CompressFormat ). |
offset |
Int: Offset into data at which the bitmap data starts |
length |
Int: Length of the bitmap data |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithFilePath
static fun createWithFilePath(path: String!): Icon
Create an Icon pointing to an image file specified by path.
Parameters | |
---|---|
path |
String!: A path to a file that contains compressed bitmap data of a type that android.graphics.BitmapFactory can decode. |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithResource
static fun createWithResource(
context: Context!,
resId: Int
): Icon
Create an Icon pointing to a drawable resource.
Parameters | |
---|---|
context |
Context!: The context for the application whose resources should be used to resolve the given resource ID. |
resId |
Int: ID of the drawable resource |
Return | |
---|---|
Icon |
This value cannot be null . |
createWithResource
static fun createWithResource(
resPackage: String!,
resId: Int
): Icon
Create an Icon pointing to a drawable resource.
Parameters | |
---|---|
resPackage |
String!: Name of the package containing the resource in question |
resId |
Int: ID of the drawable resource |
Return | |
---|---|
Icon |
This value cannot be null . |
describeContents
fun describeContents(): Int
Parcelable interface
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getResId
fun getResId(): Int
Gets the resource used to create this icon.
Only valid for icons of type TYPE_RESOURCE
. Note: This resource may not be available if the application changes at all, and it is up to the caller to ensure safety if this resource is re-used and/or persisted.
getResPackage
fun getResPackage(): String
Gets the package used to create this icon.
Only valid for icons of type TYPE_RESOURCE
. Note: This package may not be available if referenced in the future, and it is up to the caller to ensure safety if this package is re-used and/or persisted.
Return | |
---|---|
String |
This value cannot be null . |
getType
fun getType(): Int
Gets the type of the icon provided.
Note that new types may be added later, so callers should guard against other types being returned.
getUri
fun getUri(): Uri
Gets the uri used to create this icon.
Only valid for icons of type TYPE_URI
and TYPE_URI_ADAPTIVE_BITMAP
. Note: This uri may not be available in the future, and it is up to the caller to ensure safety if this uri is re-used and/or persisted.
Return | |
---|---|
Uri |
This value cannot be null . |
loadDrawable
fun loadDrawable(context: Context!): Drawable?
Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary. Depending on the type of image, this may not be something you want to do on the UI thread, so consider using loadDrawableAsync
instead.
Parameters | |
---|---|
context |
Context!: Context in which to load the drawable; used to access Resources , for example. |
Return | |
---|---|
Drawable? |
A fresh instance of a drawable for this image, yours to keep. This value may be null . |
loadDrawableAsync
fun loadDrawableAsync(
context: Context,
andThen: Message
): Unit
Invokes loadDrawable(android.content.Context)
on the given Handler
and then sends andThen
to the same Handler when finished.
Parameters | |
---|---|
context |
Context: Context in which to load the drawable; see loadDrawable(android.content.Context) This value cannot be null . |
andThen |
Message: android.os.Message to send to its target once the drawable is available. The obj property is populated with the Drawable. This value cannot be null . |
loadDrawableAsync
fun loadDrawableAsync(
context: Context,
listener: Icon.OnDrawableLoadedListener!,
handler: Handler!
): Unit
Invokes loadDrawable(android.content.Context)
on a background thread and notifies the
on the listener
handler
when finished.
Parameters | |
---|---|
context |
Context: Context in which to load the drawable; see loadDrawable(android.content.Context) This value cannot be null . |
listener |
Icon.OnDrawableLoadedListener!: to be notified when loadDrawable(android.content.Context) finished |
handler |
Handler!: Handler on which to notify the listener |
setTint
fun setTint(tint: Int): Icon
Store a color to use whenever this Icon is drawn.
Parameters | |
---|---|
tint |
Int: a color, as in Drawable#setTint(int) |
Return | |
---|---|
Icon |
this same object, for use in chained construction This value cannot be null . |
setTintBlendMode
fun setTintBlendMode(mode: BlendMode): Icon
Store a blending mode to use whenever this Icon is drawn.
Parameters | |
---|---|
mode |
BlendMode: a blending mode, as in Drawable#setTintMode(PorterDuff.Mode) , may be null |
Return | |
---|---|
Icon |
this same object, for use in chained construction This value cannot be null . |
setTintList
fun setTintList(tintList: ColorStateList!): Icon
Store a color to use whenever this Icon is drawn.
Parameters | |
---|---|
tintList |
ColorStateList!: as in Drawable#setTintList(ColorStateList) , null to remove tint |
Return | |
---|---|
Icon |
this same object, for use in chained construction This value cannot be null . |
setTintMode
fun setTintMode(mode: PorterDuff.Mode): Icon
Store a blending mode to use whenever this Icon is drawn.
Parameters | |
---|---|
mode |
PorterDuff.Mode: a blending mode, as in Drawable#setTintMode(PorterDuff.Mode) , may be null |
Return | |
---|---|
Icon |
this same object, for use in chained construction This value cannot be null . |
toString
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Parameters | |
---|---|
dest |
Parcel: The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |