student student -4 years ago 120
Android Question

setImageURI on SimpleDraweeView: callback when the image is loaded - Android

I am using this code to display an image:

SimpleDraweeView imageview = (SimpleDraweeView) findViewById(R.id.imageview);
String fileInternalPath = "....";
Uri bmpImageUri = Uri.parse(fileInternalPath);
imageview.setImageURI(bmpImageUri);


I need to know when the image is loaded so I can hide the progressbar.

Any ideas?

Answer Source

You can add controller listener to drawee view. Something like this:

 imageView.setController(Fresco.newDraweeControllerBuilder()
                    .setControllerListener(new ControllerListener<ImageInfo>() {
                        @Override
                        public void onSubmit(String id, Object callerContext) {

                        }

                        @Override
                        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {

                        }

                        @Override
                        public void onIntermediateImageSet(String id, ImageInfo imageInfo) {

                        }

                        @Override
                        public void onIntermediateImageFailed(String id, Throwable throwable) {

                        }

                        @Override
                        public void onFailure(String id, Throwable throwable) {

                        }

                        @Override
                        public void onRelease(String id) {

                        }
                    });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download