-
- All Implemented Interfaces:
-
com.mobwith.imgmodule.manager.LifecycleListener,com.mobwith.imgmodule.request.target.Target
@Deprecated() public abstract class SimpleTarget<Z> extends BaseTarget<Z>
A simple com.mobwith.imgmodule.request.target.Target base class with default (usually no-op) implementations of non essential methods that allows the caller to specify an exact width/height. Typically use cases look something like this:
Targettarget = ImageModule.with(fragment) .asBitmap() .load("http://somefakeurl.com/fakeImage.jpeg") .apply(fitCenterTransform()) .into(new SimpleTargetWarning! this class is extremely prone to mis-use. Use SimpleTarget only as a last resort. ViewTarget or a subclass of ViewTarget is almost always a better choice.
Don't forget to clear instances of this class!. If you must use this class, keep in mind that unlike ViewTarget it is not safe to load into new instances of this class repeatedly if every instance updates the same underlying View or caller. If you need to load into the same View or caller repeatedly using this class, always retain a reference to the previous instance and either call clear on the old instance before starting a new load or you must re-use the old instance for the new load. ImageModule into method returns the instance you provided to make retaining a reference to the Target as easy as possible. That said, you must wait until you're completely finished with the resource before calling clear and you should always null out references to any loaded resources in onLoadCleared.
Always try to provide a size when using this class. Use SimpleTarget whenever possible with values that are notSIZE_ORIGINAL. Using SIZE_ORIGINAL is unsafe if you're loading large images or are running your application on older or memory constrained devices because it can cause ImageModule to load very large images into memory. In some cases those images may throw OutOfMemoryError and in others they may exceed the texture limit for the device, which will prevent them from being rendered. Providing a valid size allows ImageModule to downsample large images, which can avoid issues with texture size or memory limitations. You don't have to worry about providing a size in most cases if you use ViewTarget so prefer ViewTarget over this class whenver possible.
-
-
Constructor Summary
Constructors Constructor Description SimpleTarget()Constructor for the target that uses SIZE_ORIGINAL as the target width andheight. SimpleTarget(int width, int height)Constructor for the target that takes the desired dimensions of the decoded and/or transformedresource.
-
Method Summary
Modifier and Type Method Description final voidgetSize(@NonNull() SizeReadyCallback cb)Immediately calls the given callback with the sizes given in the constructor. voidremoveCallback(@NonNull() SizeReadyCallback cb)Removes the given callback from the pending set if it's still retained. -
Methods inherited from class com.mobwith.imgmodule.request.target.BaseTarget
getRequest, onDestroy, onLoadCleared, onLoadFailed, onLoadStarted, onStart, onStop, 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
-
SimpleTarget
SimpleTarget()
Constructor for the target that uses SIZE_ORIGINAL as the target width andheight.
-
SimpleTarget
SimpleTarget(int width, int height)
Constructor for the target that takes the desired dimensions of the decoded and/or transformedresource.- Parameters:
width- The width in pixels of the desired resource.height- The height in pixels of the desired resource.
-
-
Method Detail
-
getSize
final void getSize(@NonNull() SizeReadyCallback cb)
Immediately calls the given callback with the sizes given in the constructor.
- Parameters:
cb- The callback that must be called when the size of the target has been determined
-
removeCallback
void removeCallback(@NonNull() SizeReadyCallback cb)
Removes the given callback from the pending set if it's still retained.
- Parameters:
cb- The callback to remove.
-
-
-
-