-
- All Implemented Interfaces:
-
com.mobwith.imgmodule.manager.LifecycleListener,com.mobwith.imgmodule.request.target.Target
public class AppWidgetTarget extends CustomTarget<Bitmap>
This class is used in order to display downloaded Bitmap inside an ImageView of an AppWidget 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 AppWidgetTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, Array<int> widgetIds)Constructor using an int array of widgetIds to get a handle on the Widget in order to updateit. AppWidgetTarget(Context context, int viewId, RemoteViews remoteViews, Array<int> widgetIds)Constructor using an int array of widgetIds to get a handle on the Widget in order to update itthat uses SIZE_ORIGINAL as the target width and height. AppWidgetTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, ComponentName componentName)Constructor using a ComponentName to get a handle on the Widget in order to update it. AppWidgetTarget(Context context, int viewId, RemoteViews remoteViews, ComponentName componentName)Constructor using a ComponentName, when override has been put to get a handle on the Widget inorder to update it that uses SIZE_ORIGINAL as the target width and height.
-
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
-
AppWidgetTarget
AppWidgetTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, Array<int> widgetIds)
Constructor using an int array of widgetIds to get a handle on the Widget in order to updateit.- Parameters:
context- Context to use in the AppWidgetManager initialization.width- Desired width in pixels of the bitmap that will be loaded.height- Desired height in pixels 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.widgetIds- The int[] that contains the widget ids of an application.
-
AppWidgetTarget
AppWidgetTarget(Context context, int viewId, RemoteViews remoteViews, Array<int> widgetIds)
Constructor using an int array of widgetIds to get a handle on the Widget in order to update itthat uses SIZE_ORIGINAL as the target width 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.widgetIds- The int[] that contains the widget ids of an application.
-
AppWidgetTarget
AppWidgetTarget(Context context, int width, int height, int viewId, RemoteViews remoteViews, ComponentName componentName)
Constructor using a ComponentName to get a handle on the Widget in order to update it.- Parameters:
context- Context to use in the AppWidgetManager initialization.width- Desired width in pixels of the bitmap that will be loaded.height- Desired height in pixels 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.componentName- The ComponentName that refers to our AppWidget.
-
AppWidgetTarget
AppWidgetTarget(Context context, int viewId, RemoteViews remoteViews, ComponentName componentName)
Constructor using a ComponentName, when override has been put to get a handle on the Widget inorder to update it that uses SIZE_ORIGINAL as the target width 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.componentName- The ComponentName that refers to our AppWidget.
-
-
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.
-
-
-
-