I am trying to write an AsyncTask
which takes an ImageView
and path to the image as input and loads the image in a background thread. I wanted to know how I can pass both the ImageView
and the path to the AsyncTask
? The Params
argument in the doInBackground
can hold an array
of data belonging to same class, but this is a different scenario as one of them is a View
and another one is the path to a file (String
).
One option I have, is to have the AsyncTask
as an inner class and declare the ImageView
as a class variable which can be accessed inside AsyncTask
. I don't want to do this, because the same task is used by multiple classes and it doesn't conform to the DRY policy.
Any help is appreciated.
Thanks.