Search in sources :

Example 6 with Photo

use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.

the class ImageLoadingExpandableListActivity 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 = tb.replaceAll("https:", "http:");
    Photo photo = new Photo();
    photo.url = url;
    photo.tb = tb;
    photo.title = title;
    photo.author = author;
    return photo;
}
Also used : XmlDom(com.androidquery.util.XmlDom) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo)

Example 7 with Photo

use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.

the class ImageLoadingExpandableListActivity method renderPhotos.

public void renderPhotos(String url, XmlDom xml, AjaxStatus status) {
    if (xml == null)
        return;
    List<Photo> entries = convertAll(xml);
    group1 = entries.subList(0, entries.size() / 2);
    group2 = entries.subList(entries.size() / 2, entries.size() - 1);
    listAq = new AQuery(this);
    BaseExpandableListAdapter aa = new BaseExpandableListAdapter() {

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            if (groupPosition == 0) {
                return group1.get(childPosition);
            }
            return group2.get(childPosition);
        }

        @Override
        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }

        @Override
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.content_item_s, parent, false);
            }
            Photo photo = (Photo) getChild(groupPosition, childPosition);
            AQuery aq = listAq.recycle(convertView);
            aq.id(R.id.name).text(photo.title);
            String tbUrl = photo.tb;
            if (!aq.shouldDelay(groupPosition, childPosition, isLastChild, convertView, parent, tbUrl)) {
                aq.id(R.id.tb).image(tbUrl, true, true, 0, 0, null, 0, 1);
                aq.id(R.id.name).text(photo.title);
            } else {
                aq.id(R.id.tb).clear();
                aq.id(R.id.text).text(photo.title);
            }
            return convertView;
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            if (groupPosition == 0) {
                return group1.size();
            }
            return group2.size();
        }

        @Override
        public Object getGroup(int groupPosition) {
            if (groupPosition == 0) {
                return group1;
            }
            return group2;
        }

        @Override
        public int getGroupCount() {
            if (group1 != null) {
                return 2;
            }
            return 0;
        }

        @Override
        public long getGroupId(int groupPosition) {
            return groupPosition;
        }

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.content_item_s, parent, false);
            }
            Photo photo = (Photo) getChild(groupPosition, 0);
            AQuery aq = listAq.recycle(convertView);
            aq.id(R.id.name).text(photo.title);
            String tbUrl = photo.tb;
            if (!aq.shouldDelay(groupPosition, isExpanded, convertView, parent, tbUrl)) {
                aq.id(R.id.tb).image(tbUrl, true, true, 0, 0, null, 0, 1);
            } else {
                aq.id(R.id.tb).clear();
            }
            aq.id(R.id.name).text("Group " + groupPosition);
            aq.id(R.id.meta).text("");
            return convertView;
        }

        @Override
        public boolean hasStableIds() {
            return false;
        }

        @Override
        public boolean isChildSelectable(int arg0, int arg1) {
            return false;
        }
    };
    aq.id(R.id.list).adapter(aa);
}
Also used : AQuery(com.androidquery.AQuery) BaseExpandableListAdapter(android.widget.BaseExpandableListAdapter) ViewGroup(android.view.ViewGroup) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView)

Example 8 with Photo

use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.

the class ImageLoadingGalleryActivity 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;
}
Also used : XmlDom(com.androidquery.util.XmlDom) ArrayList(java.util.ArrayList) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo)

Example 9 with Photo

use of com.androidquery.test.image.ImageLoadingList4Activity.Photo in project androidquery by androidquery.

the class ImageLoadingGalleryActivity 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;
}
Also used : XmlDom(com.androidquery.util.XmlDom) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo)

Aggregations

Photo (com.androidquery.test.image.ImageLoadingList4Activity.Photo)9 XmlDom (com.androidquery.util.XmlDom)6 View (android.view.View)3 ViewGroup (android.view.ViewGroup)3 AQuery (com.androidquery.AQuery)3 ArrayList (java.util.ArrayList)3 AdapterView (android.widget.AdapterView)2 ArrayAdapter (android.widget.ArrayAdapter)2 AbsListView (android.widget.AbsListView)1 BaseExpandableListAdapter (android.widget.BaseExpandableListAdapter)1 ExpandableListView (android.widget.ExpandableListView)1