-
- All Implemented Interfaces:
-
com.mobwith.imgmodule.manager.LifecycleListener,com.mobwith.imgmodule.request.target.Target
public class NotificationTarget extends CustomTarget<Bitmap>
This class is used to display downloaded Bitmap inside an ImageView of a Notification through RemoteViews.
Note - For cancellation to work correctly, you must pass in the same instance of this class for every subsequent load.
-
-
Constructor Summary
Constructors Constructor Description NotificationTarget(Context context, int viewId, RemoteViews remoteViews, Notification notification, int notificationId)Constructor using a Notification object and a notificationId to get a handle on theNotification in order to update it that uses SIZE_ORIGINAL as the target width andheight. NotificationTarget(Context context, int viewId, RemoteViews remoteViews, Notification notification, int notificationId, String notificationTag)Constructor using a Notification object, a notificationId, and a notificationTag to get ahandle on the Notification in order to update it that uses SIZE_ORIGINAL as the targetwidth and height. NotificationTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, Notification notification, int notificationId, String notificationTag)Constructor using a Notification object, a notificationId, and a notificationTag to get ahandle on the Notification in order to update it.
-
Method Summary
Modifier and Type Method Description voidonResourceReady(@NonNull() Bitmap resource, @Nullable() Transition<out Object> transition)The method that will be called when the resource load has finished. voidonLoadCleared(@Nullable() Drawable placeholder)A mandatory lifecycle callback that is called when a load is cancelled and its resourcesare freed. -
Methods inherited from class com.mobwith.imgmodule.request.target.CustomTarget
getRequest, getSize, onDestroy, onLoadFailed, onLoadStarted, onStart, onStop, removeCallback, setRequest -
Methods inherited from class com.mobwith.imgmodule.request.target.Target
onResourceReady -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
NotificationTarget
NotificationTarget(Context context, int viewId, RemoteViews remoteViews, Notification notification, int notificationId)
Constructor using a Notification object and a notificationId to get a handle on theNotification in order to update it that uses SIZE_ORIGINAL as the target width andheight.- Parameters:
context- Context to use in the AppWidgetManager initialization.viewId- The id of the ImageView view that will load the image.remoteViews- RemoteViews object which contains the ImageView that will load the bitmap.notification- The Notification object that we want to update.notificationId- The notificationId of the Notification that we want to load the Bitmap.
-
NotificationTarget
NotificationTarget(Context context, int viewId, RemoteViews remoteViews, Notification notification, int notificationId, String notificationTag)
Constructor using a Notification object, a notificationId, and a notificationTag to get ahandle on the Notification in order to update it that uses SIZE_ORIGINAL as the targetwidth and height.- Parameters:
context- Context to use in the AppWidgetManager initialization.viewId- The id of the ImageView view that will load the image.remoteViews- RemoteViews object which contains the ImageView that will load the bitmap.notification- The Notification object that we want to update.notificationId- The notificationId of the Notification that we want to load the Bitmap.notificationTag- The notificationTag of the Notification that we want to load the Bitmap.
-
NotificationTarget
NotificationTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, Notification notification, int notificationId, String notificationTag)
Constructor using a Notification object, a notificationId, and a notificationTag to get ahandle on the Notification in order to update it.- Parameters:
context- Context to use in the AppWidgetManager initialization.width- Desired width of the bitmap that will be loaded.(Need to be manually put becauseof RemoteViews limitations.height- Desired height of the bitmap that will be loaded.viewId- The id of the ImageView view that will load the image.remoteViews- RemoteViews object which contains the ImageView that will load the bitmap.notification- The Notification object that we want to update.notificationId- The notificationId of the Notification that we want to load the Bitmap.notificationTag- The notificationTag of the Notification that we want to load the Bitmap.
-
-
Method Detail
-
onResourceReady
void onResourceReady(@NonNull() Bitmap resource, @Nullable() Transition<out Object> transition)
The method that will be called when the resource load has finished.
- Parameters:
resource- the loaded resource.
-
onLoadCleared
void onLoadCleared(@Nullable() Drawable placeholder)
A mandatory lifecycle callback that is called when a load is cancelled and its resourcesare freed.
You must ensure that any current Drawable received in onResourceReady is no longer used before redrawing the container (usually a View) or changing itsvisibility.
- Parameters:
placeholder- The placeholder drawable to optionally show, or null.
-
-
-
-