Question

I must explain first what I have been doing for the existing version of my app : Activity needs some data from web -> Pass request bundle to an IntentService -> IntentService forms a JSON/XML request from the bundle & makes a GET/POST call to the web endpoint -> When response received, the IntentService publishes corresponding event (I am using EventBus) -> The subscribers of this event (may be activities or others) get the event and process it.

I want to migrate to Volley (or Picasso+Retrofit) because until now there was no image loading in my app, I was just consuming RESTful services. With image loading, I am afraid of memory leaks.

The problem : In my existing setup, I have the activity and service layers decoupled. But when I look at the Volley (or Picasso) samples, especially the image loading part, I see them using the views in the networking part (NetworkImageView for Volley and "into" method in Picasso). It seems un-natural to me to pass the views from my existing Activity to the Service (which will then consume Volley/Picasso to load images). Am I mis-understanding something about these libraries ? Or passing the views to services makes sense ? Or should I change my existing design ? Any example would help !

Was it helpful?

Solution

Picasso supports any arbitrary Target, not just Views. You could be using that within your Service.

Your Service in general should not know about views. I don't see the connection or problem here with using Picasso.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top