https://github.com/chrynan/glide-drawable
Asynchronous loading of Drawable Functions for the Glide library
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (4.4%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Asynchronous loading of Drawable Functions for the Glide library
Basic Info
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
glide-drawable
Lazy and asynchronous loading of Drawables with the Glide library.
Building
Base Library:
groovy
implementation 'com.github.chRyNaN.glide-drawable:library:VERSION'
Drawable Function Implementations:
groovy
implementation 'com.github.chRyNaN.glide-drawable:feature:VERSION'
Using the library
Pass in a function that returns a
Drawableinstance into Glide. The function will be resolved asynchronously and theDrawablewill be cached using Glide.kotlin Glide.with(context) .loadFunction { getMyDrawable() } .into(imageView) // Or Glide.with(context) .load(myDrawableFunctionClassImplementation) .into(imageView)Register the
DrawableFunctionclass: ```kotlin @GlideModule class SearchAppGlideModule : AppGlideModule() {override fun registerComponents(context: Context, glide: Glide, registry: Registry) { registry.prepend(DrawableFunction::class.java, Drawable::class.java, DrawableFunctionLoaderFactory()) } } ```
This approach is different from using the load(getMyDrawable()) function because that would resolve the drawable synchronously when the function is called. Passing a function to load, load(f: () -> Drawable), resolves the Drawable asynchronously.
Creating a reusable DrawableFunction
Create the implementation class: ```kotlin class ApplicationIconDrawableFunction( private val packageManager: PackageManager, private val packageName: String ) : DrawableFunction {
companion object {
private const val PACKAGE_ID_PREFIX = "application:packageName:"}
override val uniqueKey: Key get() = ObjectKey("$PACKAGEIDPREFIX$packageName")
override val function: () -> Drawable get() = { packageManager.getApplicationIcon(packageName) } } ```
Register the class: ```kotlin @GlideModule class SearchAppGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) { registry.prepend(ApplicationIconDrawableFunction::class.java, Drawable::class.java, DrawableFunctionLoaderFactory()) } } ```
Feature Library
Some common implementations of DrawableFunction are provided through the feature library. This library is optional but is useful if those implementations are needed.
The ApplicationIconDrawableFunction shown above, is provided in the feature library.
Owner
- Name: Christopher
- Login: chRyNaN
- Kind: user
- Location: Austin, TX
- Company: Starry
- Website: https://chrynan.codes
- Repositories: 15
- Profile: https://github.com/chRyNaN
GitHub Events
Total
Last Year
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Chris | c****n@s****m | 12 |
| Christopher | b****p@g****m | 3 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago