@Test public void testGetKidItems() { assertThat(item.getKidItems()).isEmpty(); item.populate(new TestItem() { @Override public long[] getKids() { return new long[]{1l, 2l}; } }); assertThat(item.getKidItems()).hasSize(2); assertEquals(1, item.getKidItems()[0].getRank()); assertEquals(2, item.getKidItems()[1].getRank()); }
@Override public HackerNewsItem[] getKidItems() { if (kids == null || kids.length == 0) { return new HackerNewsItem[0]; } if (kidItems == null) { kidItems = new HackerNewsItem[kids.length]; for (int i = 0; i < kids.length; i++) { HackerNewsItem item = new HackerNewsItem(kids[i], level + 1); item.rank = i + 1; if (i > 0) { item.previous = kids[i - 1]; } if (i < kids.length - 1) { item.next = kids[i + 1]; } kidItems[i] = item; } } return kidItems; }
HackerNewsItem implements Item { @Override public HackerNewsItem[] getKidItems() { if (kids == null || kids.length == 0) { return new HackerNewsItem[0]; } if (kidItems == null) { kidItems = new HackerNewsItem[kids.length]; for (int i = 0; i < kids.length; i++) { HackerNewsItem item = new HackerNewsItem(kids[i], level + 1); item.rank = i + 1; if (i > 0) { item.previous = kids[i - 1]; } if (i < kids.length - 1) { item.next = kids[i + 1]; } kidItems[i] = item; } } return kidItems; } }
HackerNewsItem implements Item { @Override public HackerNewsItem[] getKidItems() { if (kids == null || kids.length == 0) { return new HackerNewsItem[0]; } if (kidItems == null) { kidItems = new HackerNewsItem[kids.length]; for (int i = 0; i < kids.length; i++) { HackerNewsItem item = new HackerNewsItem(kids[i], level + 1); item.rank = i + 1; if (i > 0) { item.previous = kids[i - 1]; } if (i < kids.length - 1) { item.next = kids[i + 1]; } kidItems[i] = item; } } return kidItems; } HackerNewsItem(long id); private  HackerNewsItem(long id, int level); @Synthetic  HackerNewsItem(Parcel source); }
HackerNewsItem implements Item { @Override public HackerNewsItem[] getKidItems() { if (kids == null || kids.length == 0) { return new HackerNewsItem[0]; } if (kidItems == null) { kidItems = new HackerNewsItem[kids.length]; for (int i = 0; i < kids.length; i++) { HackerNewsItem item = new HackerNewsItem(kids[i], level + 1); item.rank = i + 1; if (i > 0) { item.previous = kids[i - 1]; } if (i < kids.length - 1) { item.next = kids[i + 1]; } kidItems[i] = item; } } return kidItems; } HackerNewsItem(long id); private  HackerNewsItem(long id, int level); @Synthetic  HackerNewsItem(Parcel source); @Override void populate(Item info); @Override String getRawType(); @Override String getRawUrl(); @Override long[] getKids(); @Override String getBy(); @Override long getTime(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override String getId(); @Override long getLongId(); @Override String getTitle(); @Override String getDisplayedTitle(); @NonNull @Override String getType(); @Override Spannable getDisplayedAuthor(Context context, boolean linkify, int color); @Override Spannable getDisplayedTime(Context context); @Override int getKidCount(); @Override int getLastKidCount(); @Override void setLastKidCount(int lastKidCount); @Override boolean hasNewKids(); @Override String getUrl(); @Override String getSource(); @Override HackerNewsItem[] getKidItems(); @Override String getText(); @Override CharSequence getDisplayedText(); @Override boolean isStoryType(); @Override boolean isFavorite(); @Override void setFavorite(boolean favorite); @Override int getLocalRevision(); @Override void setLocalRevision(int localRevision); @Override int getDescendants(); @Override boolean isViewed(); @Override void setIsViewed(boolean isViewed); @Override int getLevel(); @Override String getParent(); @Override Item getParentItem(); @Override boolean isDeleted(); @Override boolean isDead(); @Override int getScore(); @Override void incrementScore(); @Override boolean isVoted(); @Override boolean isPendingVoted(); @Override void clearPendingVoted(); @Override boolean isCollapsed(); @Override void setCollapsed(boolean collapsed); @Override int getRank(); @Override boolean isContentExpanded(); @Override void setContentExpanded(boolean expanded); @Override long getNeighbour(int direction); @Override int hashCode(); @Override boolean equals(Object o); }
HackerNewsItem implements Item { @Override public HackerNewsItem[] getKidItems() { if (kids == null || kids.length == 0) { return new HackerNewsItem[0]; } if (kidItems == null) { kidItems = new HackerNewsItem[kids.length]; for (int i = 0; i < kids.length; i++) { HackerNewsItem item = new HackerNewsItem(kids[i], level + 1); item.rank = i + 1; if (i > 0) { item.previous = kids[i - 1]; } if (i < kids.length - 1) { item.next = kids[i + 1]; } kidItems[i] = item; } } return kidItems; } HackerNewsItem(long id); private  HackerNewsItem(long id, int level); @Synthetic  HackerNewsItem(Parcel source); @Override void populate(Item info); @Override String getRawType(); @Override String getRawUrl(); @Override long[] getKids(); @Override String getBy(); @Override long getTime(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override String getId(); @Override long getLongId(); @Override String getTitle(); @Override String getDisplayedTitle(); @NonNull @Override String getType(); @Override Spannable getDisplayedAuthor(Context context, boolean linkify, int color); @Override Spannable getDisplayedTime(Context context); @Override int getKidCount(); @Override int getLastKidCount(); @Override void setLastKidCount(int lastKidCount); @Override boolean hasNewKids(); @Override String getUrl(); @Override String getSource(); @Override HackerNewsItem[] getKidItems(); @Override String getText(); @Override CharSequence getDisplayedText(); @Override boolean isStoryType(); @Override boolean isFavorite(); @Override void setFavorite(boolean favorite); @Override int getLocalRevision(); @Override void setLocalRevision(int localRevision); @Override int getDescendants(); @Override boolean isViewed(); @Override void setIsViewed(boolean isViewed); @Override int getLevel(); @Override String getParent(); @Override Item getParentItem(); @Override boolean isDeleted(); @Override boolean isDead(); @Override int getScore(); @Override void incrementScore(); @Override boolean isVoted(); @Override boolean isPendingVoted(); @Override void clearPendingVoted(); @Override boolean isCollapsed(); @Override void setCollapsed(boolean collapsed); @Override int getRank(); @Override boolean isContentExpanded(); @Override void setContentExpanded(boolean expanded); @Override long getNeighbour(int direction); @Override int hashCode(); @Override boolean equals(Object o); static final Creator<HackerNewsItem> CREATOR; }