Example usage for com.google.gwt.gdata.client.gbase ItemsEntry getFeedLink

List of usage examples for com.google.gwt.gdata.client.gbase ItemsEntry getFeedLink

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase ItemsEntry getFeedLink.

Prototype

@SuppressWarnings("unchecked")
public final native FeedLink getFeedLink() ;

Source Link

Document

Returns the nested feed link.

Usage

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

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers./*from  ww  w  . jav  a  2s .c  o m*/
 * Here, the failure handler displays an error message while the
 * success handler obtains the first item entry that is associated
 * with on or more media attachments and calls getMedia to
 * retrieve its media entries.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetItem = null;
            for (ItemsEntry entry : entries) {
                FeedLink<MediaFeed> link = entry.getFeedLink().cast();
                if (link.getCountHint() > 0) {
                    targetItem = entry;
                    break;
                }
            }
            if (targetItem == null) {
                showStatus("You have no items containing media.", false);
            } else {
                String itemsEntryUri = targetItem.getSelfLink().getHref();
                getMedia(itemsEntryUri);
            }
        }
    });
}