Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Powerful and flexible library for loading, caching and displaying images on Android.

License

NotificationsYou must be signed in to change notification settings

coder92/Android-Universal-Image-Loader

 
 

Repository files navigation

Logo Universal Image Loader

UIL aims to provide a powerful, flexible and highly customizable instrument for image loading, caching and displaying. It provides a lot of configuration options and good control over the image loading and caching process.

Screenshot

Project News

Upcoming changes in new UIL version (1.9.4+)

  • Memory Cache redesign
  • New API:DisplayImageOptions.targetSize(ImageSize)
  • HTTP cache support
  • ConsiderBitmapFactory.Options.inBitmap
  • Time-to-live option for files in LruDiskCache

Features

  • Multithread image loading (async or sync)
  • Wide customization of ImageLoader's configuration (thread executors, downloader, decoder, memory and disk cache, display image options, etc.)
  • Many customization options for every display image call (stub images, caching switch, decoding options, Bitmap processing and displaying, etc.)
  • Image caching in memory and/or on disk (device's file system or SD card)
  • Listening loading process (including downloading progress)

Android 2.0+ support

Downloads

Quick Setup

1. Include library

Manual:

  • Download JAR
  • Put the JAR in thelibs subfolder of your Android project

or

Maven dependency:

<dependency><groupId>com.nostra13.universalimageloader</groupId><artifactId>universal-image-loader</artifactId><version>1.9.3</version></dependency>

or

Gradle dependency:

compile'com.nostra13.universalimageloader:universal-image-loader:1.9.3'

2. Android Manifest

<manifest><!-- Include following permission if you load images from Internet--><uses-permissionandroid:name="android.permission.INTERNET" /><!-- Include following permission if you want to cache images on SD card--><uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />...</manifest>

3. Application or Activity class (before the first usage of ImageLoader)

publicclassMyActivityextendsActivity {@OverridepublicvoidonCreate() {super.onCreate();// Create global configuration and initialize ImageLoader with this configImageLoaderConfigurationconfig =newImageLoaderConfiguration.Builder(this)....build();ImageLoader.getInstance().init(config);...}}

Configuration and Display Options

  • ImageLoaderConfiguration (ImageLoaderConfiguration) is global for application.
  • Display Options (DisplayImageOptions) are local for every display task (ImageLoader.displayImage(...)).

Configuration

All options in Configuration builder are optional. Use only those you really want to customize.
See default values for config options in Java docs for every option.

// DON'T COPY THIS CODE TO YOUR PROJECT! This is just example of ALL options using.// See the sample project how to use ImageLoader correctly.FilecacheDir =StorageUtils.getCacheDirectory(context);ImageLoaderConfigurationconfig =newImageLoaderConfiguration.Builder(context).memoryCacheExtraOptions(480,800)// default = device screen dimensions.diskCacheExtraOptions(480,800,null).taskExecutor(...).taskExecutorForCachedImages(...).threadPoolSize(3)// default.threadPriority(Thread.NORM_PRIORITY -2)// default.tasksProcessingOrder(QueueProcessingType.FIFO)// default.denyCacheImageMultipleSizesInMemory().memoryCache(newLruMemoryCache(2 *1024 *1024)).memoryCacheSize(2 *1024 *1024).memoryCacheSizePercentage(13)// default.diskCache(newUnlimitedDiscCache(cacheDir))// default.diskCacheSize(50 *1024 *1024).diskCacheFileCount(100).diskCacheFileNameGenerator(newHashCodeFileNameGenerator())// default.imageDownloader(newBaseImageDownloader(context))// default.imageDecoder(newBaseImageDecoder())// default.defaultDisplayImageOptions(DisplayImageOptions.createSimple())// default.writeDebugLogs().build();

Display Options

Display Options can be applied to every display task (ImageLoader.displayImage(...) call).

Note: If Display Options wasn't passed toImageLoader.displayImage(...)method then default Display Options from configuration (ImageLoaderConfiguration.defaultDisplayImageOptions(...)) will be used.

// DON'T COPY THIS CODE TO YOUR PROJECT! This is just example of ALL options using.// See the sample project how to use ImageLoader correctly.DisplayImageOptionsoptions =newDisplayImageOptions.Builder().showImageOnLoading(R.drawable.ic_stub)// resource or drawable.showImageForEmptyUri(R.drawable.ic_empty)// resource or drawable.showImageOnFail(R.drawable.ic_error)// resource or drawable.resetViewBeforeLoading(false)// default.delayBeforeLoading(1000).cacheInMemory(false)// default.cacheOnDisk(false)// default.preProcessor(...).postProcessor(...).extraForDownloader(...).considerExifParams(false)// default.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)// default.bitmapConfig(Bitmap.Config.ARGB_8888)// default.decodingOptions(...).displayer(newSimpleBitmapDisplayer())// default.handler(newHandler())// default.build();

Usage

Acceptable URIs examples

StringimageUri ="http://site.com/image.png";// from WebStringimageUri ="file:///mnt/sdcard/image.png";// from SD cardStringimageUri ="content://media/external/audio/albumart/1";// from content providerStringimageUri ="assets://image.png";// from assetsStringimageUri ="drawable://" +R.drawable.img;// from drawables (non-9patch images)

NOTE: Usedrawable:// only if you really need it! Alwaysconsider the native way to load drawables -ImageView.setImageResource(...) instead of using ofImageLoader.

Simple

// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view//which implements ImageAware interface)imageLoader.displayImage(imageUri,imageView);
// Load image, decode it to Bitmap and return Bitmap to callbackimageLoader.loadImage(imageUri,newSimpleImageLoadingListener() {@OverridepublicvoidonLoadingComplete(StringimageUri,Viewview,BitmaploadedImage) {// Do whatever you want with Bitmap}});
// Load image, decode it to Bitmap and return Bitmap synchronouslyBitmapbmp =imageLoader.loadImageSync(imageUri);

Complete

// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view//which implements ImageAware interface)imageLoader.displayImage(imageUri,imageView,options,newImageLoadingListener() {@OverridepublicvoidonLoadingStarted(StringimageUri,Viewview) {...}@OverridepublicvoidonLoadingFailed(StringimageUri,Viewview,FailReasonfailReason) {...}@OverridepublicvoidonLoadingComplete(StringimageUri,Viewview,BitmaploadedImage) {...}@OverridepublicvoidonLoadingCancelled(StringimageUri,Viewview) {...}},newImageLoadingProgressListener() {@OverridepublicvoidonProgressUpdate(StringimageUri,Viewview,intcurrent,inttotal) {...}});
// Load image, decode it to Bitmap and return Bitmap to callbackImageSizetargetSize =newImageSize(80,50);// result Bitmap will be fit to this sizeimageLoader.loadImage(imageUri,targetSize,options,newSimpleImageLoadingListener() {@OverridepublicvoidonLoadingComplete(StringimageUri,Viewview,BitmaploadedImage) {// Do whatever you want with Bitmap}});
// Load image, decode it to Bitmap and return Bitmap synchronouslyImageSizetargetSize =newImageSize(80,50);// result Bitmap will be fit to this sizeBitmapbmp =imageLoader.loadImageSync(imageUri,targetSize,options);

Applications using Universal Image Loader

MediaHouse, UPnP/DLNA Browser |Prezzi Benzina (AndroidFuel) |ROM Toolbox Lite,Pro |Stadium Astro |Chef Astro |Sporee - Live Soccer Scores |EyeEm - Photo Filter Camera |PhotoDownloader for Facebook |Topface - meeting is easy |reddit is fun |Diaro - personal diary |WebMoney Keeper Mobile |LoL Memento League of Legends |Meetup |Vingle - Magazines by Fans |Anime Music Radio |WidgetLocker Theme Viewer |ShortBlogger for Tumblr |SnapDish Food Camera |Twitch |TVShow Time, TV show guide |Planning Center Services |Daybe - 일기가 되는 SNS |Lapse It |My Cloud Player for SoundCloud |SoundTracking |LoopLR Social Video |Reddit Pics HD |Hír24 |Immobilien Scout24 |Lieferheld - Pizza Pasta Sushi |Loocator: free sex datings |벨팡-개편 이벤트,컬러링,벨소리,무료,최신가요,링투유 |Streambels AirPlay/DLNA Player |Ship Mate - All Cruise Lines |Disk & Storage Analyzer |糗事百科 |Balance BY |Anti Theft Alarm - Security |XiiaLive™ - Internet Radio |Bandsintown Concerts |Save As Web Archive

Donation

You can support the project and thank the author for his hard work :)

Click here to lend your support to: Universal Image Loader for Android and make a donation at pledgie.com !Flattr this

  • PayPal - nostra.uil[at]gmail[dot]com

Alternative libraries

License

If you use Universal Image Loader code in your application you should inform the author about it (email: nostra13[at]gmail[dot]com ) like this:

Subject: UIL usage notification
Text: I use Universal Image Loader {lib_version} in {application_name} - {http://link_to_google_play}.I [allow | don't allow] to mention my app in section "Applications using Universal Image Loader" on GitHub.

Also I'll be grateful if you mention UIL in application UI with string"Using Universal Image Loader (c) 2011-2014, Sergey Tarasevich" (e.g. in some "About" section).

Copyright 2011-2014 Sergey TarasevichLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at   http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

About

Powerful and flexible library for loading, caching and displaying images on Android.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp