- using
Asynctask
- using
Glide
- using
Picaso
Last active
September 9, 2018 15:31
-
-
Save OrenBochman/098bd5e2a7b8389c50cfebe67ae057ae to your computer and use it in GitHub Desktop.
android images
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); |
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
Glide.with(this) | |
.load(imageUrl) | |
.diskCacheStrategy(DiskCacheStrategy.ALL) | |
.centerCrop() | |
.into(new GlideDrawableImageViewTarget(mDetailImage) { | |
@Override | |
public void onResourceReady(GlideDrawable resource, | |
GlideAnimation<? super GlideDrawable> animation) { | |
super.onResourceReady(resource, animation); | |
EspressoIdlingResource.decrement(); // App is idle. | |
} | |
} |
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
Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment