Skip to content

Instantly share code, notes, and snippets.

@holmeszyx
Created February 1, 2013 05:42
Show Gist options
  • Select an option

  • Save holmeszyx/4689542 to your computer and use it in GitHub Desktop.

Select an option

Save holmeszyx/4689542 to your computer and use it in GitHub Desktop.
private class ScreenDetailAdapter extends PagerAdapter{
ImageDownloaderEx mImageDownloaderEx;
String[] mUrls;
public ScreenDetailAdapter(String[] urls) {
// TODO Auto-generated constructor stub
DisplayMetrics dm = getResources().getDisplayMetrics();
SizeInfo sizeInfo = new SizeInfo(dm.widthPixels, dm.heightPixels);
sizeInfo.forDetail = true;
mImageDownloaderEx = new ImageDownloaderEx(thisInstance, sizeInfo);
this.mUrls = urls
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mUrls.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
// TODO Auto-generated method stub
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// TODO Auto-generated method stub
ImageView img = new ImageView(thisInstance);
img.setAdjustViewBounds(true);
img.setScaleType(ScaleType.FIT_CENTER);
ViewGroup.LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
img.setLayoutParams(params);
container.addView(img);
mImageDownloaderEx.download(mUrls[position], img, R.drawable.pic_rom_default_icon);
return img;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// TODO Auto-generated method stub
if (object instanceof ImageView){
ImageView img = (ImageView) object;
container.removeView(img);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment