You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In verion 4.x.x, Glide can take in custom ResourceDecoder through AppGlideModule
@GlideModule
class MyAppGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
registry.prepend(String::class.java, Bitmap::class.java, GalleryDecoder(context))
}
}
However, this will apply the custom decoder to all Glide loads. Now, after reading through Glide code, I see that the custom decoder is identified by a thing called bucket, and one of the comment in the code said You may also add custom buckets which are identified as a unique string.
So is it possible to apply the bucket (corresponding with a custom ResourceDecoder) on a specific Glide load?
We definitely made this harder in Glide 4.0, on the assumption that this use case was relatively rare and that for those cases it would be better to accept some additional overhead to reduce the clutter in the API and the number of unnecessary allocations.
The recommended way in v4 of using your own decoder is either to create custom resource types, or to replace Glide's default decoder. Since you appear to be handling standard data types and producing a standard resource type (Bitmap), the custom resource type option is more work. Instead you could consider creating your own ResourceDecoder that checks an Option to decide whether to use GalleryDecoder or Glide's default.
Buckets aren't sufficient because they apply to all loads. Buckets are a (mostly) internal tool to make sure that decoders are attempted in the order we expect.
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.
In verion 4.x.x, Glide can take in custom
ResourceDecoder
throughAppGlideModule
However, this will apply the custom decoder to all Glide loads. Now, after reading through Glide code, I see that the custom decoder is identified by a thing called
bucket
, and one of the comment in the code saidYou may also add custom buckets which are identified as a unique string
.So is it possible to apply the bucket (corresponding with a custom
ResourceDecoder
) on a specific Glide load?Note that in Glide 3.x.x, you can do this easily:
The text was updated successfully, but these errors were encountered: