Package 

Class CustomViewTarget

    • Constructor Detail

      • CustomViewTarget

        CustomViewTarget(T view)
        Constructor that defaults {@code waitForLayout} to {@code false}.
    • Method Detail

      • onStop

         void onStop()

        Callback for when onStop} or } is called.

      • waitForLayout

        @NonNull() final CustomViewTarget<T, Z> waitForLayout()

        Indicates that ImageModule should always wait for any pending layout pass before checking for thesize an View.

        By default, ImageModule will only wait for a pending layout pass if it's unable to resolve thesize from the LayoutParams or valid non-zero values for getWidth and getHeight.

        Because calling this method forces ImageModule to wait for the layout pass to occur beforestarting loads, setting this parameter to {@code true} can cause ImageModule to asynchronous load animage even if it's in the memory cache. The load will happen asynchronously because ImageModule hasto wait for a layout pass to occur, which won't necessarily happen in the same frame as whenthe image is requested. As a result, using this method can resulting in flashing in some casesand should be used sparingly.

        If the LayoutParams of the wrapped View are set to fixed sizes, they willstill be used instead of the View's dimensions even if this method is called. Thisparameter is a fallback only.

      • clearOnDetach

        @NonNull() final CustomViewTarget<T, Z> clearOnDetach()

        Clears the View's Request when the View is detached from its and restarts the Request when the View is re-attached fromits android.view.Window.

        This is an experimental API that may be removed in a future version.

        Using this method can save memory by allowing ImageModule to more eagerly clear resources whentransitioning screens or swapping adapters in scrolling views. However it also substantiallyincreases the odds that images will not be in memory if users subsequently return to a screenwhere images were previously loaded. Whether or not this happens will depend on the number ofimages loaded in the new screen and the size of the memory cache. Increasing the size of thememory cache can improve this behavior but it largely negates the memory benefits of using thismethod.

        Use this method with caution and measure your memory usage to ensure that it's actuallyimproving your memory usage in the cases you care about.

      • useTagId

        @Deprecated() final CustomViewTarget<T, Z> useTagId(@IdRes() int tagId)

        Override the android resource id to store temporary state allowing loads to be automaticallycancelled and resources re-used in scrolling lists.

        Unlike ViewTarget, it is not necessary to set a custom tag id if your appuses setTag. It is only necessary if loading several ImageModule resources intothe same view, for example one foreground and one background view.

        Parameters:
        tagId - The android resource id to use.
      • getSize

         final void getSize(@NonNull() SizeReadyCallback cb)

        Determines the size of the view by first checking getWidth and getHeight. If one or both are zero, it then checks the view's LayoutParams. If one or both of the params width and height are less than or equal tozero, it then adds an ViewTreeObserver.OnPreDrawListener which waits untilthe view has been measured before calling the callback with the view's drawn width and height.

        Parameters:
        cb - The callback that must be called when the size of the target has been determined
      • removeCallback

         final void removeCallback(@NonNull() SizeReadyCallback cb)

        Removes the given callback from the pending set if it's still retained.

        Parameters:
        cb - The callback to remove.
      • onLoadStarted

         final void onLoadStarted(@Nullable() Drawable placeholder)

        A lifecycle callback that is called when a load is started.

        Note - This may not be called for every load, it is possible for example for loads to failbefore the load starts (when the model object is null).

        Note - This method may be called multiple times before any other lifecycle method is called.Loads can be paused and restarted due to lifecycle or connectivity events and each restart maycause a call here.

        Parameters:
        placeholder - The placeholder drawable to optionally show, or null.
      • onLoadCleared

         final 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.