for (int i = 0; i < storiesElement.length(); ++i) {
JSONObject keyElement = storiesElement.getJSONObject(i);
// Cursor element
JSONObject cur = null;
DiggSearchStoryResultItem resultItem = new DiggSearchStoryResultItem();
// Story Element
resultItem.setStoryComments(keyElement.getString(STORY_COMMENTS_ATTRIBUTE));
resultItem.setDescription(keyElement.getString(DIGG_DESCRIPTION_ELEMENT));
resultItem.setStoryDiggs(keyElement.getString(STORY_DIGGS_ATTRIBUTE));
resultItem.setStoryHref(keyElement.getString(STORY_HREF_ATTRIBUTE));
resultItem.setStoryId(keyElement.getString(STORY_ID_ATTRIBUTE));
resultItem.setStoryLink(keyElement.getString(STORY_LINK_ATTRIBUTE));
resultItem.setStoryMedia(keyElement.getString(STORY_MEDIA_ATTRIBUTE));
resultItem.setStoryStatus(keyElement.getString(STORY_STATUS_ATTRIBUTE));
resultItem.setStorySubmitDate(keyElement.getString(STORY_SUBMITDATE_ATTRIBUTE));
resultItem.setTitle(keyElement.getString(DIGG_TITLE_ELEMENT));
// User Info
cur = (JSONObject)getJSONElementChecked(keyElement,DIGG_USER_ELEMENT);
if(cur!=null){
resultItem.setUserIcon(cur.getString(USER_ICON_ATTRIBUTE));
resultItem.setUserName(cur.getString(USER_NAME_ATTRIBUTE));
resultItem.setUserProfileviews(cur.getString(USER_PROFILEVIEWS_ATTRIBUTE));
resultItem.setUserRegistered(cur.getString(USER_REGISTERED_ATTRIBUTE));
/* @since digg Apis v2.0*/
resultItem.setUserFullName(cur.getString(USER_FULLNAME_ATTRIBUTE));
// TODO The links can be commented because it is irrelevant to the Stories data.
if(cur.getJSONArray(USER_LINKS_ATTRIBUTE)!=null)
resultItem.setUserLinks(cur.getJSONArray(USER_LINKS_ATTRIBUTE).toString());
}
// Topic
cur = (JSONObject)getJSONElementChecked(keyElement,DIGG_TOPIC_ELEMENT);
if(cur!=null){
resultItem.setTopicName(cur.getString(TOPIC_NAME_ATTRIBUTE));
resultItem.setTopicShortName(cur.getString(TOPIC_SHORTNAME_ATTRIBUTE));
}
// Container
cur = (JSONObject)getJSONElementChecked(keyElement,DIGG_CONTAINER_ELEMENT);
if(cur!=null){
resultItem.setContainerName(cur.getString(CONTAINER_NAME_ATTRIBUTE));
resultItem.setContainerShortName(cur.getString(CONTAINER_SHORTNAME_ATTRIBUTE));
}
// Short_url
cur = (JSONObject)getJSONElementChecked(keyElement,DIGG_SHORTURL_ELEMENT);
if(cur!=null){
resultItem.setShorturl(cur.getString(SHORTURL_URL_ATTRIBUTE));
resultItem.setShorturlViewCount(cur.getString(SHORTURL_VIEW_COUNT_ATTRIBUTE));
}
/* @since digg Apis v2.0*/
// Thumbnail
cur = keyElement.getJSONObject(DIGG_THUMBNAIL_ELEMENT);
if(cur!=null){
resultItem.setThumbnailContentType(cur.getString(THUMBNAIL_CONTENT_TYPE_ATTRIBUTE));
resultItem.setThumbnailSrc(cur.getString(THUMBNAIL_SRC_ATTRIBUTE));
resultItem.setThumbnailHeight(cur.getString(THUMBNAIL_HEIGHT_ATTRIBUTE));
resultItem.setThumbnailWidth(cur.getString(THUMBNAIL_WIDTH_ATTRIBUTE));
resultItem.setThumbnailOriginalHeight(cur.getString(THUMBNAIL_ORIGINAL_HEIGHT_ATTRIBUTE));
resultItem.setThumbnailOriginalWidth(cur.getString(THUMBNAIL_ORIGINAL_WIDTH_ATTRIBUTE));
}
// Add the populated item to the resultList
searchResultList.add(resultItem);
}