Class DynamicLoader


  • public class DynamicLoader
    extends java.lang.Object
    An Enum to load Drawable from the DrawableLruCache.
    • Method Detail

      • getInstance

        @NonNull
        public static DynamicLoader getInstance()
        Retrieves the singleton instance of DynamicLoader.

        Must be called before accessing the public methods.

        Returns:
        The singleton instance of DynamicLoader
      • getDrawableLruCache

        @Nullable
        public DrawableLruCache<java.lang.String> getDrawableLruCache()
        Returns the drawable cache used by this loader.
        Returns:
        The drawable cache used by this loader.
      • clearDrawables

        public void clearDrawables()
        Clear the drawable cache.
      • loadDrawable

        @Nullable
        public android.graphics.drawable.Drawable loadDrawable​(@NonNull
                                                               android.content.Context context,
                                                               @DrawableRes
                                                               int drawableRes)
        Load the drawable resource from the cache.
        Parameters:
        context - The context to get the resources.
        drawableRes - The drawable resource to be used.
        Returns:
        The drawable resource from the cache.
      • loadAppIcon

        @Nullable
        public android.graphics.drawable.Drawable loadAppIcon​(@NonNull
                                                              android.content.Context context,
                                                              @Nullable
                                                              java.lang.String packageName)
        Load the app icon from the cache.
        Parameters:
        context - The context to get the package manager.
        packageName - The package name to be used.
        Returns:
        The app icon from the cache.
      • setAsync

        @Nullable
        public <V,​P,​R> java.util.concurrent.Future<?> setAsync​(@Nullable
                                                                           java.util.concurrent.ExecutorService executorService,
                                                                           @Nullable
                                                                           DynamicCallback<V,​P,​R> callback)
        Set the view asynchronously by using the DynamicCallback.
        Type Parameters:
        V - The type of the callback view.
        P - The type of the callback placeholder.
        R - The type of the callback result.
        Parameters:
        executorService - The executor service to be used.
        callback - The callback to be used.
        Returns:
        The Future representing the pending completion of the task.
        See Also:
        DynamicConcurrent.async(ExecutorService, Handler, DynamicCallback)
      • setAsync

        @Nullable
        public <V,​P,​R> java.util.concurrent.Future<?> setAsync​(@Nullable
                                                                           DynamicCallback<V,​P,​R> callback)
        Set the view asynchronously by using the DynamicCallback.
        Type Parameters:
        V - The type of the callback view.
        P - The type of the callback placeholder.
        R - The type of the callback result.
        Parameters:
        callback - The callback to be used.
        Returns:
        The Future representing the pending completion of the task.
        See Also:
        DynamicConcurrent.async(Handler, DynamicCallback)