Gallery
ウィジェットで使用する遅延ロード アダプターを作成したいと考えています。
つまりgetView()
、すぐに を返し、ImageView
後で他のメカニズムがそのsetImageBitmap()
メソッドを非同期的に呼び出します。ImageView
拡張する「怠惰な」を作成することでこれを行いましたImageView
。
public class GalleryImageView extends ImageView {
// ... other stuff here ...
public void setImage(final Looper looper, final int position) {
final Uri uri = looper.get(position);
final String path = looper.sharePath(position);
new Thread(new Runnable() {
@Override
public void run() {
GalleryBitmap gbmp = new GalleryBitmap(context, uri, path);
final Bitmap bmp = gbmp.getBitmap(); // all the work is here
handler.post(new Runnable() {
@Override
public void run() {
if (GalleryImageView.this.getTag().equals(uri)) {
setImageBitmap(bmp);
}
}
});
}
}).start();
}
}
でゆっくりスクロールするとGallery
、中央の画像が中央に飛び出し続けます。正確に説明するのは難しいですが、本当に面倒です。スピナーアダプターにも同じアプローチを試みましたが、そこでは完全に機能します。
何か案は?