Android open-source project: Image download cache library picasso

Source: Internet
Author: User

Android open-source project: Image download cache library picasso

Picasso is an open-source Android image cache library of Square. The address is http://square.github.io/picasso/. you can download and save images.

Picasso has the following features:

  • Reclaim and cancel the current download in the adapter;
  • Complex graphic conversion operations with minimal memory;
  • Automatic Memory and hard disk cache;
  • Graphic conversion operations, such as resizing and rotating, provide interfaces for users to customize conversion operations;
  • Load network or local resources;
  • It can be converted to the desired request (another open-source network support library of Square: retrofit supports conversion of json and protoc0l buffers ).

    1. simple use of picasso:

    1 Picasso. with (context ). load (url ). placeholder (R. drawable. pic ). error (R. drawable. pic ). into (tagert); Note: When the url is an http link, load (url). When the url is a local image path, load (new File (url )). A simple image processing is required: transform (Transformation); The following shows a circular image.
    // Overload function public Bitmap transform (Bitmap source) {int width = source. getWidth (); int height = source. getHeight (); int x = 0, y = 0; if (mSquareRound & width! = Height) {if (width 
    transform(new RoundTransformation(true));

    2. the picasso class diagram is as follows:

    A Brief Introduction to key classes:

    Cache: Cache class. The sub-class LruCache uses Least Recently Used to use at Least the algorithm Recently. Of course, javashashmap has implemented this policy and trimToSize Based on the configured Cache size.

    The picass Cache Policy is single. There is no other Image download cache library Android-universal-Image-Loader. There are many cache policies: FIFOLimitedMemZ? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> memory + memory/memory + Memory + LXsMDgo6zWrrrzsNHL + Memory + rHtwcvSu7j2vt/memory + examples/examples + examples/examples + zzKOsvbu4 + examples/O0psDtwOCjrNfTwOC4 + examples/templates + CiA8L3A + examples + templates = "http://www.2cto.com/uploadfile/Collfiles/20141203/2014120309104861.png" alt = "\">

    4. possible problems with picasso:

    1. sometimes the image cannot be displayed. view the cached image file in the application. For an image, two files are generated :,. file 0 stores the corresponding http response information ,. 1. Encrypted image file .. The content of file 0 is as follows:

    http://192.168.2.40:82/group1/M00/0A/60/wKgCKFQJQkKABEn9AAPhsEdiW-o.phpzqfGET0HTTP/1.1 200 OK9Server: nginx/1.2.6Date: Tue, 16 Sep 2014 12:02:26 GMTContent-Length: 254384Last-Modified: Fri, 05 Sep 2014 04:55:30 GMTConnection: keep-aliveAccept-Ranges: bytesOkHttp-Selected-Protocol: http/1.1OkHttp-Sent-Millis: 1410868547182OkHttp-Received-Millis: 1410868547357

    Content-Length: 0, but the image does exist. If it is not displayed, you can view it in this regard. Feasible Method:

    Customizes Downloader and configures the cache directory and cache size.

    2. When picasso displays a large number of images in the list, oom occurs when you view the large image. In addition to compressing the aspect ratio, you can also view the large image in another process.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.