Class AppWidgetTarget
- java.lang.Object
-
- com.bumptech.glide.request.target.CustomTarget<android.graphics.Bitmap>
-
- com.bumptech.glide.request.target.AppWidgetTarget
-
- All Implemented Interfaces:
LifecycleListener,Target<android.graphics.Bitmap>
public class AppWidgetTarget extends CustomTarget<android.graphics.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.
-
-
Field Summary
-
Fields inherited from interface com.bumptech.glide.request.target.Target
SIZE_ORIGINAL
-
-
Constructor Summary
Constructors Constructor Description AppWidgetTarget(android.content.Context context, int width, int height, int viewId, android.widget.RemoteViews remoteViews, int... widgetIds)Constructor using an int array of widgetIds to get a handle on the Widget in order to update it.AppWidgetTarget(android.content.Context context, int width, int height, int viewId, android.widget.RemoteViews remoteViews, android.content.ComponentName componentName)Constructor using a ComponentName to get a handle on the Widget in order to update it.AppWidgetTarget(android.content.Context context, int viewId, android.widget.RemoteViews remoteViews, int... widgetIds)Constructor using an int array of widgetIds to get a handle on the Widget in order to update it that usesTarget.SIZE_ORIGINALas the target width and height.AppWidgetTarget(android.content.Context context, int viewId, android.widget.RemoteViews remoteViews, android.content.ComponentName componentName)Constructor using a ComponentName, when override has been put to get a handle on the Widget in order to update it that usesTarget.SIZE_ORIGINALas the target width and height.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonLoadCleared(android.graphics.drawable.Drawable placeholder)A mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.voidonResourceReady(android.graphics.Bitmap resource, Transition<? super android.graphics.Bitmap> transition)The method that will be called when the resource load has finished.-
Methods inherited from class com.bumptech.glide.request.target.CustomTarget
getRequest, getSize, onDestroy, onLoadFailed, onLoadStarted, onStart, onStop, removeCallback, setRequest
-
-
-
-
Constructor Detail
-
AppWidgetTarget
public AppWidgetTarget(android.content.Context context, int width, int height, int viewId, android.widget.RemoteViews remoteViews, int... widgetIds)Constructor using an int array of widgetIds 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. (Needs to be manually put because of RemoteViews limitations.)height- Desired height in pixels of the bitmap that will be loaded. (Needs to be manually put because of RemoteViews limitations.)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
public AppWidgetTarget(android.content.Context context, int viewId, android.widget.RemoteViews remoteViews, int... widgetIds)Constructor using an int array of widgetIds to get a handle on the Widget in order to update it that usesTarget.SIZE_ORIGINALas 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
public AppWidgetTarget(android.content.Context context, int width, int height, int viewId, android.widget.RemoteViews remoteViews, android.content.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. (Needs to be manually put because of RemoteViews limitations.)height- Desired height in pixels of the bitmap that will be loaded. (Needs to be manually put because of RemoteViews limitations.)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
public AppWidgetTarget(android.content.Context context, int viewId, android.widget.RemoteViews remoteViews, android.content.ComponentName componentName)Constructor using a ComponentName, when override has been put to get a handle on the Widget in order to update it that usesTarget.SIZE_ORIGINALas 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
public void onResourceReady(@NonNull android.graphics.Bitmap resource, @Nullable Transition<? super android.graphics.Bitmap> transition)Description copied from interface:TargetThe method that will be called when the resource load has finished.- Parameters:
resource- the loaded resource.
-
onLoadCleared
public void onLoadCleared(@Nullable android.graphics.drawable.Drawable placeholder)Description copied from interface:TargetA mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.You must ensure that any current Drawable received in
Target.onResourceReady(Object, Transition)is no longer used before redrawing the container (usually a View) or changing its visibility.- Parameters:
placeholder- The placeholder drawable to optionally show, or null.
-
-