ㄷㅣㅆㅣ's Amusement

[Android/Java] Glide, An Image Loader. -- 1. Overview 본문

Programming/Android

[Android/Java] Glide, An Image Loader. -- 1. Overview

ㄷㅣㅆㅣ 2016. 11. 2. 18:59

[Android/Java] Glide, An Image Loader. -- 1. Overview

반응형

Glide

you will save yourself a lot of time & headache.



  • Why use glide?
    • Android is not good when working with images, since it will load images into the memory pixel by pixel.
    • Google introduce this library(Glide) in Google I/O 2015.
    • Even Google official application uses Glide.
  • example
    • 1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          if (null == convertView) {
              convertView = inflater.inflate(R.layout.imageView, parent, false);
          }
           Glide
              .with(context)
              .load(images[position])
              .into((ImageView) convertView);
           return convertView;
      }

      c

  • Save yourself a lot of time & headache.
    • Automatically resource re-use.
      • Glide automatically takes care of the request canceling, clearing of the ImageViews.
      • Glide load the correct image into the appropriate ImageView.
      • So, You don’t need to make any code to image control for scrolling in “getView()”
    • Cache policy
      • Glide uses three sources: memory, disk and network. but, there is nothing coder will have to do.
      • Glide hides all that complexity from coder, while creating intelligently sized caches for coder.
    • Memory-wise
      • In comparison to Picasso, Glide is much more efficient memory-wise.
      • Glide automatically limits the size of the image it holds in cache and memory to the ImageView dimensions.
      • Picasso also has the same ability, but requires a call to fit().
    • Additional Function
      • Placeholder
      • Error-Placeholder
      • Crossfade animation. (default 300ms)
      • 1
        2
        3
        4
        5
        6
        7
        Glide  
            .with(context)
            .load("http://www.childc.co.kr/some_image.png")
            .placeholder(R.mipmap.ic_launcher) // can also be a drawable
            .error(R.mipmap.future_studio_launcher) // will be displayed if the image cannot be loaded
            .crossfade()
            .into(imageViewError);
        cs
      • Displaying Gifs (Nothing is different from image)
      • Displaying Thumbnail of video



반응형
Comments