The below example code will helps you to get Image from URL by using glide library and to wait for image until it loaded. For this in below example I have added glide library in build.gradle file then I am using Glide with MainActivity class and get (position) into imageView.In below example when you have clicked on button then image will get displayed from URL.
Step(1)-I have added first glide library in build.gradle file
compile 'com.github.bumptech.glide:glide:3.7.0'
Step(2)-MainActivity -
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//progressBar
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.setVisibility(View.VISIBLE);
//Using Glide class
Glide.with(MainActivity.this)
.load("http://www.androidbegin.com/tutorial/flag/unitedstates.png")
.into(new GlideDrawableImageViewTarget(image) {
@Override
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
super.onResourceReady(drawable, anim);
progressBar.setVisibility(View.GONE);
}
});
0 Comment(s)