Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

This blog is part of 1 Tute Sets.

Android Video Tutorials For Beginners to Learn Mobile App Development
prev 1 3 7
  • Android Image Loading Libraries Video Tutorial

    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1
    • 1.39k
    Comment on it

    In this Android Video Tutorial I am guiding about four different libraries for loading images using URL:

    • Universal Image Loader
    • Picasso
    • Glide
    • Fresco

    Along with I am explaining their description, performance and implementation procedure is also added in this tutorial.

     

    You can use these libraries by adding following dependencies and their implementation code:

    1. Universal Image Loader:-

    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(this).build();
            ImageLoader imageLoader = ImageLoader.getInstance();
            imageLoader.init(imageLoaderConfiguration);
    
            DisplayImageOptions options = new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.drawable.placeholder) // resource or drawable
                    .showImageForEmptyUri(R.drawable.empty) // resource or drawable
                    .showImageOnFail(R.drawable.failed) // resource or drawable
                    .delayBeforeLoading(1000)
                    .resetViewBeforeLoading(true)  // default
                    .cacheInMemory(true) // default => false
                    .cacheOnDisk(true) // default => false
                    .build();
    
            imageLoader.displayImage(imageURI, ivImage, options, new ImageLoadingListener() {
                @Override
                public void onLoadingStarted(String imageUri, View view) {
                    Toast.makeText(getApplicationContext(), "Loading Started", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                    Toast.makeText(getApplicationContext(), "Loading Failed", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    Toast.makeText(getApplicationContext(), "Loading Complete", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onLoadingCancelled(String imageUri, View view) {
                    Toast.makeText(getApplicationContext(), "Loading Cancelled", Toast.LENGTH_SHORT).show();
                }
            });


    2. Picasso:-

    compile 'com.squareup.picasso:picasso:2.5.2'
    Picasso.with(this)
                    .load(imageURI)
                    .placeholder(R.drawable.placeholder)
                    .error(R.drawable.failed)
                    .into(ivImage);


    3. Glide:-

    compile 'com.github.bumptech.glide:glide:3.6.1'
    Glide.with(this)
                    .load(imageURI)
                    .placeholder(R.drawable.placeholder)
                    .error(R.drawable.failed)
                    .into(ivImage);


    4. Fresco:-

    compile 'com.facebook.fresco:fresco:0.14.1'
    ControllerListener controllerListener = new ControllerListener() {
                @Override
                public void onSubmit(String id, Object callerContext) {
                    Toast.makeText(ImageLoaderActivity.this, "Called before the image request is submitted", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onFinalImageSet(String id, Object imageInfo, Animatable animatable) {
                    Toast.makeText(ImageLoaderActivity.this, "When final image is loaded", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onIntermediateImageSet(String id, Object imageInfo) {
                    Toast.makeText(ImageLoaderActivity.this, "When intermediate image is Loaded", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onIntermediateImageFailed(String id, Throwable throwable) {
                    Toast.makeText(ImageLoaderActivity.this, "While intermediate image loading failed", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onFailure(String id, Throwable throwable) {
                    Toast.makeText(ImageLoaderActivity.this, "Image Loading failed", Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onRelease(String id) {
                    Toast.makeText(ImageLoaderActivity.this, "When controller releases the fetched Image", Toast.LENGTH_SHORT).show();
                }
            };
    
            Uri imageUri = Uri.parse(imageURI);
            DraweeController controller = Fresco.newDraweeControllerBuilder()
                    .setUri(imageUri)
                    .setControllerListener(controllerListener)
                    .setAutoPlayAnimations(true)
                    .build();
    
            sdvImage.setController(controller);

     

    I had also attached image loader demo file, you can download it for further reference.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: