use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.
the class ImageGridFragment method render.
private void render(List<Photo> entries) {
AQUtility.debug("render setup");
ArrayAdapter<Photo> aa = new ArrayAdapter<Photo>(getActivity(), R.layout.grid_item2, entries) {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = aq.inflate(convertView, R.layout.grid_item2, parent);
}
Photo photo = getItem(position);
AQuery aq = aq2.recycle(convertView);
String tbUrl = photo.tb;
if (aq.shouldDelay(position, convertView, parent, tbUrl)) {
//aq.id(R.id.tb).image(placeholder);
aq.id(R.id.tb).clear();
} else {
aq.id(R.id.tb).image(tbUrl, true, true, 200, R.drawable.image_missing, null, 0, 0);
}
return convertView;
}
};
aq.id(R.id.grid).adapter(aa);
}
use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.
the class ImageLoadingGalleryActivity method renderPhotos.
/*
private boolean shouldDelayG(int position, View convertView, ViewGroup parent, String url){
if(url == null) return false;
boolean hit = BitmapAjaxCallback.getMemoryCached(url, 0) != null;
if(hit){
return false;
}
Gallery gallery = (Gallery) parent;
Integer selected = (Integer) gallery.getTag(AQuery.TAG_LAYOUT);
if(selected == null){
selected = 0;
gallery.setTag(AQuery.TAG_LAYOUT, 0);
gallery.setCallbackDuringFling(false);
Common common = new Common();
common.listen(gallery);
}
int first = gallery.getFirstVisiblePosition();
int last = gallery.getLastVisiblePosition();
int diff = last - first;
int delta = (diff / 2) + 1;
int from = selected - delta;
int to = selected + delta;
if(from < 0){
//shift window back to positive region
to = to - from;
from = 0;
}
if((position >= from && position <= to)){
AQUtility.debug("yes", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_LAYOUT, position);
return false;
}
AQUtility.debug("no", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_LAYOUT, null);
return true;
}
*/
public void renderPhotos(String url, XmlDom xml, AjaxStatus status) {
if (xml == null)
return;
List<Photo> entries = convertAll(xml);
listAq = new AQuery(this);
ArrayAdapter<Photo> aa = new ArrayAdapter<Photo>(this, R.layout.gallery_item, entries) {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.gallery_item, parent, false);
}
Photo photo = getItem(position);
AQuery aq = listAq.recycle(convertView);
aq.id(R.id.name).text(photo.title);
String tbUrl = photo.tb;
if (!aq.shouldDelay(position, convertView, parent, tbUrl)) {
aq.id(R.id.tb).image(tbUrl, true, true, 100, 0);
aq.id(R.id.text).text(photo.title).gone();
} else {
aq.id(R.id.tb).clear();
aq.id(R.id.text).text(photo.title).visible();
}
return convertView;
}
};
aq.id(R.id.gallery).adapter(aa);
}
use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.
the class ImageGridFragment method convert.
private Photo convert(XmlDom xml) {
String url = xml.child("content").attr("src");
String title = xml.child("title").text();
String author = xml.child("author").text("name");
String tb = url;
List<XmlDom> tbs = xml.tags("media:thumbnail");
if (tbs.size() > 0) {
//tb = tbs.get(0).attr("url");
tb = tbs.get(tbs.size() - 1).attr("url");
}
tb = tb.replaceAll("https:", "http:");
Photo photo = new Photo();
photo.url = url;
photo.tb = tb;
photo.title = title;
photo.author = author;
return photo;
}
use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.
the class ImageGridFragment method convertAll.
private List<Photo> convertAll(XmlDom xml) {
List<XmlDom> entries = xml.children("entry");
List<Photo> result = new ArrayList<Photo>();
for (XmlDom entry : entries) {
result.add(convert(entry));
}
return result;
}
use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.
the class ImageLoadingExpandableListActivity method convertAll.
private List<Photo> convertAll(XmlDom xml) {
List<XmlDom> entries = xml.children("entry");
List<Photo> result = new ArrayList<Photo>();
for (XmlDom entry : entries) {
result.add(convert(entry));
}
return result;
}
Aggregations