public final class AvatarManager extends Manager
This class manages avatar updates as described in XEP-0153: vCard-Based Avatars and XEP-0084: User Avatar.
Whenever an avatar update is received by a contact, either via the presence based avatar extension (XEP-0153) or the PEP-based notification (XEP-0084), the registered listeners are triggered.
By default this manager is not enabled.
This class is thread-safe.Modifier and Type | Method and Description |
---|---|
void |
addAvatarChangeListener(java.util.function.Consumer<AvatarChangeEvent> avatarChangeListener)
Adds an avatar listener, to listen for avatar updates.
|
AsyncResult<byte[]> |
getAvatar(Jid contact)
Gets the user avatar from the user’s vCard.
|
AsyncResult<java.awt.image.BufferedImage> |
getAvatarImage(Jid contact)
Gets the user avatar from the user’s vCard.
|
AsyncResult<java.lang.Void> |
publishAvatar(byte[] imageData)
Publishes an avatar to your VCard.
|
AsyncResult<java.lang.Void> |
publishAvatarImage(java.awt.image.BufferedImage bufferedImage)
Publishes an avatar to your VCard.
|
void |
removeAvatarChangeListener(java.util.function.Consumer<AvatarChangeEvent> avatarChangeListener)
Removes a previously added avatar listener.
|
isEnabled, setEnabled
public final AsyncResult<byte[]> getAvatar(Jid contact)
Gets the user avatar from the user’s vCard.
contact
- The contact.public final AsyncResult<java.awt.image.BufferedImage> getAvatarImage(Jid contact)
Gets the user avatar from the user’s vCard.
contact
- The contact. Must not be null
.public final AsyncResult<java.lang.Void> publishAvatar(byte[] imageData)
Publishes an avatar to your VCard.
imageData
- The avatar image data, which must be in PNG format. null
resets the avatar.public final AsyncResult<java.lang.Void> publishAvatarImage(java.awt.image.BufferedImage bufferedImage) throws XmppException
Publishes an avatar to your VCard.
bufferedImage
- The avatar image, which must be in PNG format. null
resets the avatar.XmppException
- If the image could not be converted to PNG.public final void addAvatarChangeListener(java.util.function.Consumer<AvatarChangeEvent> avatarChangeListener)
Adds an avatar listener, to listen for avatar updates.
avatarChangeListener
- The avatar listener.public final void removeAvatarChangeListener(java.util.function.Consumer<AvatarChangeEvent> avatarChangeListener)
Removes a previously added avatar listener.
avatarChangeListener
- The avatar listener.Copyright © 2014–2019 XMPP.rocks. All rights reserved.