Skip to content

Instantly share code, notes, and snippets.

@teshi04
Created February 9, 2015 19:02
Show Gist options
  • Save teshi04/0434dbd5ed41c753d1ec to your computer and use it in GitHub Desktop.
Save teshi04/0434dbd5ed41c753d1ec to your computer and use it in GitHub Desktop.
昔書いたやつ
## picasso
https://github.com/square/picasso
- 機能が豊富
- 複雑な画像の変形処理を最小のメモリ消費で実現できる
- 自動でメモリ・ファイルキャッシュをやってくれる
- デバッグ機能がある。読み込まれた画像がネットワーク・メモリ・ディスクのどこから読まれたのか分かるように画像の上に印が表示されるようにする機能と、詳細なログが出力される機能がある。
## UniversalImageLoader
https://github.com/nostra13/Android-Universal-Image-Loader
- 機能が豊富
- 設定オプションが豊富
- ディスクキャッシュやメモリキャッシュも簡単実装
- キャッシュする時はディレクトリの容量やファイル数で制限できる
- 失敗時の画像を表示したりも可能
- 設定がめんどくさい
- Androidの画像読み込みライブラリUniversal Image Loader for Androidがすごい便利 by @chuross on @Qiita http://qiita.com/chuross/items/e3ca79065d9b67716ace
## Volley
https://android.googlesource.com/platform/frameworks/volley
- 速いらしい
- ImageCacheクラスを継承してキャッシュ処理のクラスを実装しなければならない
## UrlImageViewHelper
https://github.com/koush/UrlImageViewHelper
- 速いらしい
- シンプルで機能が少ない
- 流行ってない
## Android Query
https://github.com/androidquery/androidquery
- 画像読み込みのライブラリではなくて、Android アプリの実装を jQuery のようにコーディングできるようにするライブラリ。UI に関わる処理や非同期処理などをメソッドチェーンなどを利用して簡潔に記述することができる。画像読み込みも簡潔に書ける
- 画像をセットする image() を使ったが引数が多くてごちゃごちゃしていてダサかった
- mavenにないから導入が面倒くさい
- 半年くらい開発止まっている。2013年前半に少し話題になった様子。今はもう終わったコンテンツ
- Android Tips #49 Android Query を使って jQuery 風に超シンプルにコーディングする|クラスメソッドブログ http://dev.classmethod.jp/smartphone/android/android-tips-49-aquery/
## Glide
https://github.com/bumptech/glide
- 動画の静止画(サムネイル?)、画像、アニメーションGIFの、デコードと表示ができる
- ネットからGIF画像を取得して表示できて便利
# 使ってみる
// 1枚画像を読み込む。読み込み完了前はプレスホルダー画像を表示する。メモリキャッシュする。
// Picasso
Picasso picasso = new Picasso.Builder(this).build();
// デバッグ
picasso.setIndicatorsEnabled(true);
picasso.setLoggingEnabled(true);
ImageView picassoImageView = (ImageView) findViewById(R.id.picasso_image_view);
picasso.load(IMAGE_URL).placeholder(R.drawable.ic_launcher).into(picassoImageView);
// UniversalImageLoader
DisplayImageOptions defaultOptions = new DisplayImageOptions
.Builder()
.cacheInMemory(true)
.showImageOnLoading(R.drawable.ic_launcher)
.resetViewBeforeLoading(true)
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration
.Builder(this)
.defaultDisplayImageOptions(defaultOptions)
.build();
com.nostra13.universalimageloader.core.ImageLoader imageLoader = com.nostra13.universalimageloader.core.ImageLoader.getInstance();
imageLoader.init(config);
ImageView uilImageView = (ImageView) findViewById(R.id.uil_image_view);
imageLoader.displayImage(IMAGE_URL, uilImageView);
// Volley
NetworkImageView volleyImageView = (NetworkImageView) findViewById(R.id.volley_image_view);
RequestQueue queue = Volley.newRequestQueue(this);
volleyImageView.setDefaultImageResId(R.drawable.ic_launcher);
volleyImageView.setImageUrl(IMAGE_URL, new com.android.volley.toolbox.ImageLoader(queue, new BitmapCache()));
// UrlImageViewHelper
ImageView uivhImageView = (ImageView) findViewById(R.id.uivh_image_view);
UrlImageViewHelper.setUrlDrawable(uivhImageView, IMAGE_URL, R.drawable.ic_launcher);
// Android Query
AQuery aq = new AQuery(this);
aq.id(R.id.aq_image_view).image(IMAGE_URL, true, false, 100, R.drawable.ic_launcher);
// Glide
Glide.with(this)
.load(IMAGE_URL)
.placeholder(R.drawable.ic_launcher)
.into((ImageView) findViewById(R.id.glide_image_view));
// Glide Gif
Glide.with(this).load(GIF_URL).asGif().into((ImageView) findViewById(R.id.glide_gif_image_view));
# 結論
picasso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment