public void loadImage() { int start = mListView.getFirstVisiblePosition(); int end = mListView.getLastVisiblePosition(); if (end >= getCount()) { end = getCount() - 1; } syncImageLoader.setLoadLimit(start, end); syncImageLoader.unlock(); }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case AbsListView.OnScrollListener.SCROLL_STATE_FLING: syncImageLoader.lock(); break; case AbsListView.OnScrollListener.SCROLL_STATE_IDLE: loadImage(); break; case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: syncImageLoader.lock(); break; default: break; } }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(R.layout.food_item, null); } Food food = mFoodList.get(position); convertView.setTag(position); ImageView img = (ImageView) convertView.findViewById(R.id.img); TextView name = (TextView) convertView.findViewById(R.id.name); name.setText(food.getName()); img.setBackgroundResource(R.drawable.ic_launcher); syncImageLoader.loadImage(position, food.getS_photo_url(), imageLoadListener); return convertView; }