Android Custom Picture Loading frame

Source: Internet
Author: User

Ideas:

1. Compress pictures

Compress local Pictures: get the ImageView you want to display, and set the appropriate insamplesize

Compress Network pictures:

A. HDD cache on/off direct download to SD card, then use local compression scheme

B. hard disk cache off, using Bitmapfactory.decodestream (IS, null, opts);

2. Picture Loading architecture

Picture compression loaded---put LRUCache----set to ImageView

1, a singleton, including a lrucache for managing our images;
2, Task queue, every time we load a picture request, we will encapsulate into a task to deposit our taskqueue;
3, contains a background thread, this thread is started the first time the instance initialization, and then will be running in the background; What about the task? Remember we have a task queue, there is a queue to save the task, someone has to work ah; So, when every time we load a picture request, we send a message to the background thread, the background thread to use the thread pool to Taskqueue to fetch a task execution;
4, scheduling strategy; 3 said that the background thread to Taskqueue to fetch a task, this task is not random, there are strategies to choose, one is FIFO, one is LIFO, I tend to the latter.

Android Custom Picture Loading frame

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.