https://github.com/chrynan/glide-drawable

Asynchronous loading of Drawable Functions for the Glide library

https://github.com/chrynan/glide-drawable

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

android android-library glide glideimageloader glidev4 kotlin kotlin-android

Keywords from Contributors

federated parcel
Last synced: 5 months ago · JSON representation

Repository

Asynchronous loading of Drawable Functions for the Glide library

Basic Info
  • Host: GitHub
  • Owner: chRyNaN
  • License: apache-2.0
  • Language: Kotlin
  • Default Branch: master
  • Homepage:
  • Size: 75.2 KB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
android android-library glide glideimageloader glidev4 kotlin kotlin-android
Created over 7 years ago · Last pushed over 7 years ago
Metadata Files
Readme License

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 Drawable instance into Glide. The function will be resolved asynchronously and the Drawable will be cached using Glide. kotlin Glide.with(context) .loadFunction { getMyDrawable() } .into(imageView) // Or Glide.with(context) .load(myDrawableFunctionClassImplementation) .into(imageView)

  • Register the DrawableFunction class: ```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

GitHub Events

Total
Last Year

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 15
  • Total Committers: 2
  • Avg Commits per committer: 7.5
  • Development Distribution Score (DDS): 0.2
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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