use of greendroid.widget.PagedAdapter in project simplefacebook by androidquery.
the class ImageActivity method initView.
private void initView() {
photos = new ArrayList<FeedItem>();
pv = (PagedView) findViewById(R.id.paged);
pi = (PageIndicator) findViewById(R.id.page_indicator);
pv.setOnPageChangeListener(new OnPagedViewChangeListener() {
@Override
public void onStopTracking(PagedView pagedView) {
}
@Override
public void onStartTracking(PagedView pagedView) {
}
@Override
public void onPageChanged(PagedView pagedView, int previousPage, int newPage) {
pi.setActiveDot(newPage);
}
});
adapter = new PagedAdapter() {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position >= photos.size())
return PageAdapter.getEmptyView(parent);
FeedItem item = photos.get(position);
String url = item.getSource();
if (url == null)
return PageAdapter.getEmptyView(parent);
String name = item.getItemName();
View cached = photoViews.get(url);
if (cached == null) {
convertView = aq.inflate(null, R.layout.item_photo, parent);
photoViews.put(url, convertView);
} else {
convertView = cached;
return convertView;
}
PQuery aq = aq2.recycle(convertView);
aq.id(R.id.web).progress(R.id.progress).invisible();
AQUtility.debug("image load url", url);
aq.webImage(url, true, false, 0xFF000000);
aq.id(R.id.text).text(name, BufferType.NORMAL, true);
convertView.setDrawingCacheEnabled(true);
return convertView;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return photos.get(position);
}
@Override
public int getCount() {
return photos.size();
}
};
pv.setAdapter(adapter);
}
Aggregations