Package rocks.xmpp.extensions.avatar
Class AbstractAvatarManager
- java.lang.Object
-
- rocks.xmpp.extensions.avatar.AbstractAvatarManager
-
- All Implemented Interfaces:
AvatarManager
- Direct Known Subclasses:
CombinedAvatarManager
,UserAvatarProtocol
,VCardBasedAvatarsProtocol
public abstract class AbstractAvatarManager extends Object implements AvatarManager
An abstract avatar manager, which provides a common implementation for both avatar protocols.- See Also:
AvatarManager
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAvatarChangeListener(Consumer<AvatarChangeEvent> avatarChangeListener)
Adds an avatar listener, to listen for avatar updates.AsyncResult<BufferedImage>
getAvatarImage(Jid contact)
Gets the user avatar.byte[]
loadFromCache(String hash)
AsyncResult<Void>
publishAvatarImage(BufferedImage bufferedImage)
Publishes an avatar.void
removeAvatarChangeListener(Consumer<AvatarChangeEvent> avatarChangeListener)
Removes a previously added avatar listener.void
storeToCache(String hash, byte[] image)
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rocks.xmpp.extensions.avatar.AvatarManager
getAvatar, publishAvatar
-
-
-
-
Method Detail
-
loadFromCache
public final byte[] loadFromCache(String hash)
-
storeToCache
public final void storeToCache(String hash, byte[] image)
-
getAvatarImage
public final AsyncResult<BufferedImage> getAvatarImage(Jid contact)
Description copied from interface:AvatarManager
Gets the user avatar.- Specified by:
getAvatarImage
in interfaceAvatarManager
- Parameters:
contact
- The contact. Must not benull
.- Returns:
- The async result with the contact's avatar or null, if it has no avatar.
-
publishAvatarImage
public final AsyncResult<Void> publishAvatarImage(BufferedImage bufferedImage) throws XmppException
Description copied from interface:AvatarManager
Publishes an avatar.- Specified by:
publishAvatarImage
in interfaceAvatarManager
- Parameters:
bufferedImage
- The avatar image, which must be in PNG format.null
resets the avatar.- Returns:
- The async result.
- Throws:
XmppException
- If the image could not be converted to PNG.
-
addAvatarChangeListener
public void addAvatarChangeListener(Consumer<AvatarChangeEvent> avatarChangeListener)
Adds an avatar listener, to listen for avatar updates.- Specified by:
addAvatarChangeListener
in interfaceAvatarManager
- Parameters:
avatarChangeListener
- The avatar listener.- See Also:
AvatarManager.removeAvatarChangeListener(Consumer)
-
removeAvatarChangeListener
public void removeAvatarChangeListener(Consumer<AvatarChangeEvent> avatarChangeListener)
Removes a previously added avatar listener.- Specified by:
removeAvatarChangeListener
in interfaceAvatarManager
- Parameters:
avatarChangeListener
- The avatar listener.- See Also:
AvatarManager.addAvatarChangeListener(Consumer)
-
-