instanceof not working on references while loading images with AsyncTask in Android -


i had deep @ documentation here http://developer.android.com/training/displaying-bitmaps/process-bitmap.html , used guide http://android-developers.blogspot.in/2010/07/multithreading-for-performance.html create imageloader handle concurrency asynchtasks.

my code same , in particular have code below pretty identical:

private static bitmapdownloadertask getbitmapdownloadertask(imageview imageview) {     if (imageview != null) {         drawable drawable = imageview.getdrawable();         if (drawable instanceof downloadeddrawable) {             downloadeddrawable downloadeddrawable = (downloadeddrawable)drawable;             return downloadeddrawable.getbitmapdownloadertask();         }     }     return null; } 

the problem condition

drawable instanceof downloadeddrawable

is never verified. looks drawable seems not instance of downloadeddrawable class , don't know why. can me?

edit: i've found related references. indeed, imageview.getdrawable() returns object has bitmapdrawable reference

android.graphics.drawable.bitmapdrawable@yyyyyyyy 

if try cast downloadeddrawable object (instance of customized subclass) or use instanceof operator on it, have error because object accessed dowanloadeddrawable reference

my_package.image_loader.downloadeddrawable@xxxxxxxx 

how fix this?

i highly recommend skip reinventing wheel image downloading. there great open source libraries handle simple downloads , make easy manage disk , memory caching.

i've worked on picasso myself there uil , few others should try.

both libraries handle adapterview recycling , perform ton of other tasks.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -