If you think the Android project image-loader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.novoda.imageloader.demo.activity;
//fromwww.java2s.comimport android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter.ViewBinder;
import com.novoda.imageloader.core.OnImageLoadedListener;
import com.novoda.imageloader.core.model.ImageTag;
import com.novoda.imageloader.core.model.ImageTagFactory;
import com.novoda.imageloader.demo.DemoApplication;
import com.novoda.imageloader.demo.R;
import com.novoda.imageloader.demo.activity.base.ImageLoaderBaseActivity;
import java.util.Locale;
/**
* This is an example using really big images and see how the image loader can keep up with the memory limitations of android.
*/publicclass BigImages extends ImageLoaderBaseActivity implements OnImageLoadedListener {
privatestaticfinal String TAG = DemoApplication.class.getSimpleName().toLowerCase(Locale.UK);
@Override
protected String getTableName() {
return BigImages.class.getSimpleName().toLowerCase(Locale.UK);
}
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**
* TODO Need to prepare imageLoader and imageTagFactory, generally we keep and instance of ImageManager and ImageTagFactory
*/
initImageLoader();
}
privatevoid initImageLoader() {
imageManager = DemoApplication.getImageLoader();
imageTagFactory = ImageTagFactory.newInstance(this, R.drawable.bg_img_loading);
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
setAnimationFromIntent(imageTagFactory);
}
@Override
protectedvoid onResume() {
super.onResume();
imageManager.setOnImageLoadedListener(this);
}
@Override
protectedvoid onPause() {
super.onPause();
imageManager.unRegisterOnImageLoadedListener(this);
}
@Override
publicvoid onImageLoaded(ImageView imageView) {
Log.v(TAG, "onImageLoaded");
Log.i(TAG, "ImageView URL : " + ((ImageTag) imageView.getTag()).getUrl());
}
/**
* TODO Generally you will have a binder where you have to set the tag and load the image.
*/
@Override
protected ViewBinder getViewBinder() {
returnnew ViewBinder() {
@Override
publicboolean setViewValue(View view, Cursor cursor, int columnIndex) {
String url = cursor.getString(columnIndex);
setImageTag((ImageView) view, url);
loadImage((ImageView) view);
return true;
}
};
}
privatevoid setImageTag(ImageView view, String url) {
view.setTag(imageTagFactory.build(url, this));
}
privatevoid loadImage(ImageView view) {
imageManager.getLoader().load(view);
}
}