开发者

finding a GroupContactEntry needle in a gData hackstack ...?

Is there a better way to obtain the Id of a specific ContactGroupEntry from your开发者_StackOverflow中文版 gData contacts without having to retrieve and iterate through the entire List?

    // contactsService has been properly initialized...
    // hunting for the groupNameId corrisponding to the plaintext groupName

    final URL url = new URL("http://www.google.com/m8/feeds/groups/default/full");
    String groupNameId = null;
    ContactGroupFeed f = contactsService.getFeed(url, ContactGroupFeed.class);
    int totalResults = f.getTotalResults();
    List<ContactGroupEntry> list = f.getEntries();
    while (list.size() < totalResults) {
        Query q = new Query(url);
        q.setStartIndex(f.getStartIndex() + f.getItemsPerPage());
        q.setMaxResults(200);
        f = this.contactsService.query(q, ContactGroupFeed.class);
        list.addAll(f.getEntries());        
    }

    for(ContactGroupEntry g : list) {
        if (groupName.compareTo(g.getPlainTextContent()) == 0) {
            groupNameId = g.getId();
            break;
        }
    }
    // return groupNameId 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜