Share a third-party Program (from github) That asynchronously retrieves network images and scales them in Android)

Source: Internet
Author: User

Because of the limited mobile phone traffic, when using Android phones, we should consider for users as much as possible to consume less user traffic, in applications, the display of network images is undoubtedly the most traffic-consuming. Therefore, we can compress images or cache images so that images can be obtained only once.

 = = = ==            Options op =             op.inSampleSize = 2= =  Rect(0, 0, 0, 0=            bitmap = 
String CACHE_DIR = "/save path of the image on your mobile phone" Map <String, SoftReference <Bitmap> List <Task> isRunning = LogoLoader (Context ctx. ctx = caches = HashMap <String, SoftReference <Bitmap> = ArrayList <LogoLoader. task> isRunning = showImageAsyn (ImageView imageView, String url, = (bitmap =} BitmapDrawable bd = SoftReference <Bitmap> rf = Bitmap bitmap = (bitmap = Task task = (! ImageCallback getImageCallback (BitmapDrawable bd = Handler handler = Task task = Runnable runnable = (taskQueue. size ()> 0 Task task = taskQueue. remove (0 &&! = File ("/mnt/sdcard/jijie/imagecache/" + (file. exists () & file. length ()> 100 = "/mnt/sdcard/jijie/imagecache/" + 10 = 10 = 100 (handler! = Message msg = (= Write (String imageurl, === BufferedOutputStream (0 index = path. lastIndexOf ("/" path. substring (index + 1 netSataus = (cwjManager. getActiveNetworkInfo ()! =

Although the above Code can achieve asynchronous acquisition of images, automatic cache reading, and image compression, It is a headache to process images to adapt to the size of controls, in addition, if a large number of network images are obtained together, a large amount of memory will be occupied, and the system will be released only when the interface is destroyed by default, therefore, it is easy to encounter memory overflow. I will share with you a program for processing network images that I saw on github.

The following is an example:

Take an image in jijie.com (www. jijie. cc) as an example. The source image is:

 

  

   

This shows the same image in different sizes. The Code just cut the image to avoid stretching and deformation, the asynchronous acquisition and automatic cache of programs will not be displayed. You can just read the code.

Engineering files (Baidu Network Disk): http://pan.baidu.com/s/1mguh2qc

Github: https://github.com/yimengqingqiu/Android-Universal-Image-Loader

Personal email: standopen@foxmail.com (you can also send me an email)

 

 

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.