第三方库写能看的文档有多重要?
2015-09-25 15:51
323 查看
最近赶项目,用到一些第三方库,发现一些看起来比原来的使用更好的库
例如加载图片,可以说几乎是我们必备的一个工具。
看下下面两个
Android-Universal-Image-Loader和Facebook开源的一个Fresco
后者
(1) 支持流式,可以类似网页上模糊渐进式显示图片
(2) 对多帧动画图片支持更好,如 Gif、WebP
(3) 更多样的显示,如圆角、进度条、点击重试、自定义对焦点
(4) 更多样的加载,如支持 EXIF、全面支持 WebP
(5) 支持 Android 2.3+
牛逼吧?,我看了也流口水,Facebook就是大法好,功能多,AUIL只支持图片的加载显示功能啊,太单一了! 必须使用。在来看下介绍详细页面:
NOTE: Use
## Using Fresco in your application
If you are building with Gradle, simply add the following line to the
For full details, visit the documentation on our web site, available in English, Chinese, and Korean:
另外推荐一个库:
它可以最大性能地在 Android 设备上读取、解码、显示图片和视频。
Glide 可以将远程的图片、视频、动画图片等缓存在设备本地便于提高用户浏览图片的流畅体验。
特点:
(1) GIF 动画的解码
(2) 本地视频剧照的解码
(3) 支持缩略图
(4) Activity 生命周期的集成
(5) 转码的支持
(6) 动画的支持
(7) OkHttp 和 Volley 的支持
Glide is a fast and efficient open source media management and image loading framework for Android that wraps media
decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.
Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible API
that allows developers to plug in to almost any network stack. By default Glide uses a custom
stack, but also includes utility libraries plug in to Google’s Volley project or Square’s OkHttp library instead.
Glide’s primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is
also effective for almost any case where you need to fetch, resize, and display a remote image.
Or use Gradle:
Or Maven:
Simple use cases will look something like this:
The integration libraries are available via Maven or the releases page.
For instructions on including either the OkHttp or the Volley integration libraries, see the Integration Libraries wiki page.
app and in the 2014 Google IO app. Version 4 is currently under development on the
Comments/bugs/questions/pull requests welcome!
Note: Make sure your Android SDK has the Android Support Repository installed, and that your
variable is pointing at the SDK or add a
You may also find precompiled APKs on the releases page.
Intellij IDEA 14 cleanly imports both Glide’s source and tests and is the recommended way to work with Glide.
To open the project in Intellij 14:
Go to File menu or the Welcome Screen
Click on Open…
Navigate to Glide’s root directory.
Select
anything else, join or email Glide’s discussion group, or join our IRC channel: irc.freenode.net#glide-library.
Dave Smith for the gif decoder gist Glide’s gif decoder is based on.
Chris Banes for his gradle-mvn-push script.
Corey Hall for Glide’s amazing logo.
Everyone who has contributed code and reported issues!
屌屌的,不错,Fresco这个就弃用了。其实打开他们的文档网站看了,还是很清晰的,
不过如果可以还是写在你的README里面吧,
简单直接,对我友好我就多看几眼,不行我不是逼不得已不会用。
这可能是为何AUIL是最受欢迎的原因啊。直接写着怎么用啊。
另外要想编译Fresco来运行一次,那还真的不容易,不信你试下。
例如加载图片,可以说几乎是我们必备的一个工具。
看下下面两个
Android-Universal-Image-Loader和Facebook开源的一个Fresco
后者
Fresco支持:
(1) 支持流式,可以类似网页上模糊渐进式显示图片
(2) 对多帧动画图片支持更好,如 Gif、WebP
(3) 更多样的显示,如圆角、进度条、点击重试、自定义对焦点
(4) 更多样的加载,如支持 EXIF、全面支持 WebP
(5) 支持 Android 2.3+
牛逼吧?,我看了也流口水,Facebook就是大法好,功能多,AUIL只支持图片的加载显示功能啊,太单一了! 必须使用。在来看下介绍详细页面:
比较介绍页面
1. AUIL的Usage
Acceptable URIs examples
"http://site.com/image.png" // from Web "file:///mnt/sdcard/image.png" // from SD card "file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail) "content://media/external/images/media/13" // from content provider "content://media/external/video/media/13" // from content provider (video thumbnail) "assets://image.png" // from assets "drawable://" + R.drawable.img // from drawables (non-9patch images)
NOTE: Use
drawable://only if you really need it! Always consider the native way to load drawables -
ImageView.setImageResource(...)instead of using of
ImageLoader.
Simple
ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance
// 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 callback imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // Do whatever you want with Bitmap } });
// Load image, decode it to Bitmap and return Bitmap synchronously Bitmap bmp = 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, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { ... } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { ... } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { ... } @Override public void onLoadingCancelled(String imageUri, View view) { ... } }, new ImageLoadingProgressListener() { @Override public void onProgressUpdate(String imageUri, View view, int current, int total) { ... } });
// Load image, decode it to Bitmap and return Bitmap to callback ImageSize targetSize = new ImageSize(80, 50); // result Bitmap will be fit to this size imageLoader.loadImage(imageUri, targetSize, options, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // Do whatever you want with Bitmap } });
// Load image, decode it to Bitmap and return Bitmap synchronously ImageSize targetSize = new ImageSize(80, 50); // result Bitmap will be fit to this size Bitmap bmp = imageLoader.loadImageSync(imageUri, targetSize, options);
AUIL小结
好,快速的看了下,会用了,就两行代码。ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance imageLoader.displayImage(imageUri, imageView);
2. Fresco
接着来看下我们的Fresco表现## Using Fresco in your application
If you are building with Gradle, simply add the following line to the
dependenciessection of your
build.gradlefile:
compile 'com.facebook.fresco:fresco:0.7.0+'
For full details, visit the documentation on our web site, available in English, Chinese, and Korean:
小结
啊。。。挺好的,还有三种语言的版本。行了,找别的库看看去了,这个下次有空再点击连接来看吧。另外推荐一个库:
3. Glide
Glide它可以最大性能地在 Android 设备上读取、解码、显示图片和视频。
Glide 可以将远程的图片、视频、动画图片等缓存在设备本地便于提高用户浏览图片的流畅体验。
特点:
(1) GIF 动画的解码
(2) 本地视频剧照的解码
(3) 支持缩略图
(4) Activity 生命周期的集成
(5) 转码的支持
(6) 动画的支持
(7) OkHttp 和 Volley 的支持
看看他的README怎么写的
Glide
Glide is a fast and efficient open source media management and image loading framework for Android that wraps media
decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.
Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible API
that allows developers to plug in to almost any network stack. By default Glide uses a custom
HttpUrlConnectionbased
stack, but also includes utility libraries plug in to Google’s Volley project or Square’s OkHttp library instead.
Glide’s primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is
also effective for almost any case where you need to fetch, resize, and display a remote image.
Download
You can download a jar from GitHub’s releases page.Or use Gradle:
repositories { mavenCentral() } dependencies { compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.android.support:support-v4:19.1.0' }
Or Maven:
<dependency> <groupId>com.github.bumptech.glide</groupId> <artifactId>glide</artifactId> <version>3.6.1</version> <type>aar</type> </dependency> <dependency> <groupId>com.google.android</groupId> <artifactId>support-v4</artifactId> <version>r7</version> </dependency>
Proguard
Depending on your proguard config and usage, you may need to include the following lines in your proguard.cfg:-keep public class * implements com.bumptech.glide.module.GlideModule -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { **[] $VALUES; public *; }
How do I use Glide?
Checkout the GitHub wiki for pages on a variety of topics, and see the javadocs.Simple use cases will look something like this:
// For a simple view: @Override public void onCreate(Bundle savedInstanceState) { ... ImageView imageView = (ImageView) findViewById(R.id.my_image_view); Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView); } // For a simple image list: @Override public View getView(int position, View recycled, ViewGroup container) { final ImageView myImageView; if (recycled == null) { myImageView = (ImageView) inflater.inflate(R.layout.my_image_view, container, false); } else { myImageView = (ImageView) recycled; } String url = myUrls.get(position); Glide.with(myFragment) .load(url) .centerCrop() .placeholder(R.drawable.loading_spinner) .crossFade() .into(myImageView); return myImageView; }
OkHttp and Volley
Support for OkHttp and Volley is provided by integration libraries you can optionally include as dependencies.The integration libraries are available via Maven or the releases page.
For instructions on including either the OkHttp or the Volley integration libraries, see the Integration Libraries wiki page.
Android SDK Version
Glide requires a minimum SDK version of 10.License
BSD, part MIT and Apache 2.0. See the LICENSE file for details.Status
Version 3 is a stable public release used in multiple open source projects at Google including in the Android Cameraapp and in the 2014 Google IO app. Version 4 is currently under development on the
masterbranch.
Comments/bugs/questions/pull requests welcome!
Build
Building Glide with gradle is fairly straight forward:git clone git@github.com:bumptech/glide.git # use https://github.com/bumptech/glide.git if "Permission Denied" cd glide git submodule init && git submodule update ./gradlew jar
Note: Make sure your Android SDK has the Android Support Repository installed, and that your
$ANDROID_HOMEenvironment
variable is pointing at the SDK or add a
local.propertiesfile in the root project with a
sdk.dir=...line.
Samples
Follow the steps in the Build section to setup the project and then:./gradlew :samples:flickr:run ./gradlew :samples:giphy:run ./gradlew :samples:svg:run
You may also find precompiled APKs on the releases page.
Development
Follow the steps in the Build section to setup the project and then edit the files however you wish.Intellij IDEA 14 cleanly imports both Glide’s source and tests and is the recommended way to work with Glide.
To open the project in Intellij 14:
Go to File menu or the Welcome Screen
Click on Open…
Navigate to Glide’s root directory.
Select
build.gradle
Getting Help
To report a specific problem or feature request, open a new issue on Github. For questions, suggestions, oranything else, join or email Glide’s discussion group, or join our IRC channel: irc.freenode.net#glide-library.
Contributing
Before submitting pull requests, contributors must sign Google’s individual contributor license agreement.Thanks
The Android team and Jake Wharton for the disk cache implementation Glide’s disk cache is based on.Dave Smith for the gif decoder gist Glide’s gif decoder is based on.
Chris Banes for his gradle-mvn-push script.
Corey Hall for Glide’s amazing logo.
Everyone who has contributed code and reported issues!
Author
Sam Judd - @samajuddDisclaimer
This is not an official Google product.屌屌的,不错,Fresco这个就弃用了。其实打开他们的文档网站看了,还是很清晰的,
不过如果可以还是写在你的README里面吧,
简单直接,对我友好我就多看几眼,不行我不是逼不得已不会用。
这可能是为何AUIL是最受欢迎的原因啊。直接写着怎么用啊。
另外要想编译Fresco来运行一次,那还真的不容易,不信你试下。
相关文章推荐
- swift开发笔记8 - sqlite3数据的使用(xcode 7,ios9)
- USB驱动——USB配置
- java获取相对时间 1小时前 1天前
- 函数指针数组
- win7下sqlite3cmd下中文乱码
- 【Android】 从头搭建视频播放器(2)——SystemMediaPlayerImpl
- iOS项目开发实战——UIView的层级关系
- 关与RVDS2.2仿真时AXD的configure target 里面是空的问题解决
- 解决后台传到前台的值是中文乱码的问题
- WPF解析TTF 字体
- MyEclipse导入的项目js文件乱码
- 内部接口
- java日期时间操作
- Sip响应状态码功能对照详解
- Porting openwrt on MT7688 Log
- JQuery DataTable 1.10服务端分页实现
- thrift
- Spotlight on MySQL监控MySQL服务器
- iOS图片瘦身总结
- Cstyle的UEFI导读:第21.0篇 UEFI的N种实现及差别