Example usage for com.google.gwt.gdata.client FeedLink getCountHint

List of usage examples for com.google.gwt.gdata.client FeedLink getCountHint

Introduction

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

Prototype

public final native double getCountHint() ;

Source Link

Document

Returns the hint at the number of entries in the feed.

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./*  w w  w.jav  a2 s  .c  om*/
 * 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);
            }
        }
    });
}