@Test public void testGetDisplayedTime() { item.populate(new TestItem() { @Override public long getTime() { return 1429027200l; } @Override public String getBy() { return "author"; } }); assertThat(item.getDisplayedAuthor(RuntimeEnvironment.application, true, 0)) .contains(" - author"); assertThat(item.getDisplayedAuthor(RuntimeEnvironment.application, false, 0)) .contains(" - author"); item.populate(new TestItem() { @Override public String getBy() { return "author"; } @Override public boolean isDead() { return true; } }); assertThat(item.getDisplayedTime(RuntimeEnvironment.application)) .contains(RuntimeEnvironment.application.getString(R.string.dead_prefix)); }
@Override public Spannable getDisplayedTime(Context context) { if (displayedTime == null) { SpannableStringBuilder builder = new SpannableStringBuilder(dead ? context.getString(R.string.dead_prefix) + " " : ""); SpannableString timeSpannable = new SpannableString( AppUtils.getAbbreviatedTimeSpan(time * 1000)); if (deleted) { timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } builder.append(timeSpannable); displayedTime = builder; } return displayedTime; }
HackerNewsItem implements Item { @Override public Spannable getDisplayedTime(Context context) { if (displayedTime == null) { SpannableStringBuilder builder = new SpannableStringBuilder(dead ? context.getString(R.string.dead_prefix) + " " : ""); SpannableString timeSpannable = new SpannableString( AppUtils.getAbbreviatedTimeSpan(time * 1000)); if (deleted) { timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } builder.append(timeSpannable); displayedTime = builder; } return displayedTime; } }
HackerNewsItem implements Item { @Override public Spannable getDisplayedTime(Context context) { if (displayedTime == null) { SpannableStringBuilder builder = new SpannableStringBuilder(dead ? context.getString(R.string.dead_prefix) + " " : ""); SpannableString timeSpannable = new SpannableString( AppUtils.getAbbreviatedTimeSpan(time * 1000)); if (deleted) { timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } builder.append(timeSpannable); displayedTime = builder; } return displayedTime; } HackerNewsItem(long id); private  HackerNewsItem(long id, int level); @Synthetic  HackerNewsItem(Parcel source); }
HackerNewsItem implements Item { @Override public Spannable getDisplayedTime(Context context) { if (displayedTime == null) { SpannableStringBuilder builder = new SpannableStringBuilder(dead ? context.getString(R.string.dead_prefix) + " " : ""); SpannableString timeSpannable = new SpannableString( AppUtils.getAbbreviatedTimeSpan(time * 1000)); if (deleted) { timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } builder.append(timeSpannable); displayedTime = builder; } return displayedTime; } 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 Spannable getDisplayedTime(Context context) { if (displayedTime == null) { SpannableStringBuilder builder = new SpannableStringBuilder(dead ? context.getString(R.string.dead_prefix) + " " : ""); SpannableString timeSpannable = new SpannableString( AppUtils.getAbbreviatedTimeSpan(time * 1000)); if (deleted) { timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } builder.append(timeSpannable); displayedTime = builder; } return displayedTime; } 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; }