question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Picasso.newBuilder()

See original GitHub issue

We 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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JakeWhartoncommented, Mar 7, 2018

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.

0reactions
JakeWhartoncommented, Mar 7, 2018

The separate cache problem is also present in OkHttp (albeit on disk instead of memory) and hasn’t been a problem in practice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

com.squareup.picasso3.Picasso$Builder.<init> java code examples ...
Add a transformer that observes and potentially modify all incoming requests. callFactory. Specify the call factory to be used for network requests. Note: ......
Read more >
Android Picasso library, How to add authentication headers?
networkInterceptors is an immutable list in OkHttp3, you can't add to it directly, you need to use a builder. OkHttpClient.Builder builder = new...
Read more >
How to add picasso library in android studio? - Tutorialspoint
Before getting into picasso library example, we should know about picasso. ... Step 2 − Add the following code in build.gradle.
Read more >
[Solved] Android Picasso, How to add authentication headers?
I'm using Picasso library to download images from api endpoint: Picasso.get().load(imgUrl).into(holder.mImgProfileView);.
Read more >
Java Examples for com.squareup.picasso.OkHttpDownloader
public void setPicasso() { OkHttpClient client = new OkHttpClient(); client.networkInterceptors().add(new StethoInterceptor()); File cache = new File(this.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found