tbiehn / Android-Adapter-Image-Loader

Optimized asynchronous multithreaded image loading library for AdapterViews.

Home Page:http://www.travisbiehn.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a free library for android apps released under the WTFPL v2.

It provides functionality for the Asynchronous loading of images in rows of an AdapterView and avoids
calling offscreen image requests.

It uses two low priority worker threads which work off a bound-length LIFO stack. The length of the 
stack is determined by the visible rows of the parent AdapterView.

Use LegacyAdapterImageLoader for API levels under 9.

Use with your efficient convertView getView algorithms!

Example usage:
public class X extends ListActivity {
 ...
 private AdapterImageLoader imageLoader;
 
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  imageLoader = new AdapterImageLoader(this.getListView());
  ...
  setListAdapter(new ArrayAdapter<...>(getActivity(),
		  ..., ...) {
		  ...
	  @Override
	  public View getView(int position, View convertView, ViewGroup parent) {
		  ...
		  final ImageView pic = (ImageView) convertView
				  .findViewById(...);
				  //Clear the old one from createView
		  pic.setImageBitmap(null);
		  try {
			  imageLoader.addImage(new URL("HTTP://URL"), pic);
		  } catch (Exception e) {
			  e.printStackTrace();
		  }
		  }
		  return convertView;
	  }
  });

 }
}

For ListFragments move the imageLoader set into onActivityCreated(...)

About

Optimized asynchronous multithreaded image loading library for AdapterViews.

http://www.travisbiehn.com

License:Do What The F*ck You Want To Public License


Languages

Language:Java 100.0%