Class DynamicLoader
- java.lang.Object
-
- com.pranavpandey.android.dynamic.util.loader.DynamicLoader
-
public class DynamicLoader extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearDrawables()Clear the drawable cache.DrawableLruCache<java.lang.String>getDrawableLruCache()Returns the drawable cache used by this loader.static DynamicLoadergetInstance()Retrieves the singleton instance ofDynamicLoader.android.graphics.drawable.DrawableloadAppIcon(android.content.Context context, java.lang.String packageName)Load the app icon from the cache.android.graphics.drawable.DrawableloadDrawable(android.content.Context context, int drawableRes)Load the drawable resource from the cache.<V,P,R>
java.util.concurrent.Future<?>setAsync(DynamicCallback<V,P,R> callback)Set the view asynchronously by using theDynamicCallback.<V,P,R>
java.util.concurrent.Future<?>setAsync(java.util.concurrent.ExecutorService executorService, DynamicCallback<V,P,R> callback)Set the view asynchronously by using theDynamicCallback.
-
-
-
Method Detail
-
getInstance
@NonNull public static DynamicLoader getInstance()
Retrieves the singleton instance ofDynamicLoader.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 theDynamicCallback.- 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
Futurerepresenting 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 theDynamicCallback.- 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
Futurerepresenting the pending completion of the task. - See Also:
DynamicConcurrent.async(Handler, DynamicCallback)
-
-