Add Picasso.newBuilder()
See original GitHub issueWe have a screen in our app that wants to keep a memory cache of images it loads for as long as we’re in the screen’s scope and then evict all the screen’s Bitmaps from the cache when the scope is torn down. Right now, there’s a very old fork of Picasso that added tags to Requests and then evicts all Bitmaps with the tag from a single cache.
While not exactly the same, a better solution might be to do Picasso.newBuilder() on the existing Picasso instance, replace the cache with a new one, and build() to make a Picasso with a new Dispatcher with a new cache.
Without newBuilder(), I’ll need to pass down the Downloader (and any other customizations) manually to this screen’s scope creation instead of just the Picasso instance.
Open to a newBuilder()
API?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Biggest use case I can see here is adding/changing handlers with scope. Same thing happens with Moshi adapter, Retrofit converters/call adapters, and OkHttp interceptors. You don’t want to pass around builder objects so you each scope has an instance of the real thing and then the scopes which build upon it call
newBuilder()
and modify to taste.The separate cache problem is also present in OkHttp (albeit on disk instead of memory) and hasn’t been a problem in practice.