Created
February 26, 2015 14:55
-
-
Save mustafasevgi/f4c0ce40105fc7ced93e to your computer and use it in GitHub Desktop.
Adapter load image and change view visibility in asynctask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using an AsyncTask to load the slow images in a background thread | |
new AsyncTask<ViewHolder, Void, Bitmap>() { | |
private ViewHolder v; | |
@Override | |
protected Bitmap doInBackground(ViewHolder... params) { | |
v = params[0]; | |
return mFakeImageLoader.getImage(); | |
} | |
@Override | |
protected void onPostExecute(Bitmap result) { | |
super.onPostExecute(result); | |
if (v.position == position) { | |
// If this item hasn't been recycled already, hide the | |
// progress and set and show the image | |
v.progress.setVisibility(View.GONE); | |
v.icon.setVisibility(View.VISIBLE); | |
v.icon.setImageBitmap(result); | |
} | |
} | |
}.execute(holder); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment