Example usage for com.google.gwt.gdata.client.contacts ContactFeedCallback ContactFeedCallback

List of usage examples for com.google.gwt.gdata.client.contacts ContactFeedCallback ContactFeedCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.contacts ContactFeedCallback ContactFeedCallback.

Prototype

ContactFeedCallback

Source Link

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.ContactsDeleteContactDemo.java

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * On success, obtain the first contact entry with a title starting
 * with "GWT-Contacts-Client", this is the contact that will be deleted.
 * If no contact is found, display a message.
 * Otherwise call deleteContact to delete the contact entry.
 * Alternatively we could also have used targetContact.deleteEntry to
 * delete the contact, but the effect is the same.
 * /*from   ww w. jav a 2 s.c o  m*/
 * @param contactsFeedUri The contacts feed uri.
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            ContactEntry targetContact = null;
            for (ContactEntry contact : entries) {
                String title = contact.getTitle().getText();
                if (title.startsWith("GWT-Contacts-Client")) {
                    targetContact = contact;
                    break;
                }
            }
            if (targetContact == null) {
                showStatus("No contacts were found that were modified today and "
                        + "contained 'GWT-Contacts-Client' in the title.", false);
            } else {
                String contactEntryUri = targetContact.getEditLink().getHref();
                deleteContact(contactEntryUri, targetContact.getEtag());
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.ContactsRetrieveContactGroupMembersDemo.java

License:Apache License

/**
 * Retrieves a contacts feed for a group using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the contacts feed, the contact
 * entries are displayed to the user via the showData method.
 * A string parameter is used to indicate the ID of the group
 * to query./*from   ww w. j a v  a  2 s  .  co  m*/
 * 
 * @param contactGroupId The id of the group for which to retrieve
 * the contacts
 */
private void queryContacts(String contactGroupId) {
    showStatus("Loading contacts feed...", false);
    ContactQuery query = ContactQuery.newInstance("http://www.google.com/m8/feeds/contacts/default/full");
    query.setStringParam("group", contactGroupId);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("The contact group has no member contacts.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.ContactsRetrieveContactsDemo.java

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the contacts feed, the contact entries
 * are displayed to the user via the showData method.
 * The MaxResults parameter is used to limit the number of entries
 * returned./*from w ww .j  ava 2 s.  co m*/
 * 
 * @param contactsFeedUri The contacts feed uri.
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Loading contacts feed...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    query.setMaxResults(50);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("You have no Contacts.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.ContactsRetrieveContactsUsingQueryDemo.java

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * We query for contacts updated today, sorted descending.
 * Upon successfully receiving the contacts feed, the contact entries
 * are displayed to the user via the showData method.
 * The UpdatedMin and SortOrder parameters are used to limit
 * the number of contact entries retrieved and to specify how they
 * should sorted.//  w  ww.  jav  a 2  s  .co m
 * 
 * @param contactsFeedUri The contacts feed uri.
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No contacts were found that were modified today.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.ContactsUpdateContactDemo.java

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * On success, obtain the first contact entry with a title starting
 * with "GWT-Contacts-Client", this is the contact that will be updated.
 * If no contact is found, display a message.
 * Otherwise call updateContact to update the contact.
 * /* w w  w.ja v a 2 s .c om*/
 * @param contactsFeedUri The contacts feed uri
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            ContactEntry targetContact = null;
            for (ContactEntry contact : entries) {
                String title = contact.getTitle().getText();
                if (title.startsWith("GWT-Contacts-Client")) {
                    targetContact = contact;
                    break;
                }
            }
            if (targetContact == null) {
                showStatus("No contacts were found that were modified today and "
                        + "contained 'GWT-Contacts-Client' in the title.", false);
            } else {
                updateContact(targetContact);
            }
        }
    });
}