use of io.github.hidroh.materialistic.data.Item in project materialistic by hidroh.
the class StoryView method setStory.
public void setStory(@NonNull WebItem story, int hotThreshold) {
if (!mIsLocal && story instanceof Item) {
Item item = (Item) story;
boolean hot = item.getScore() >= hotThreshold * AppUtils.HOT_FACTOR;
mScoreTextView.setTextColor(hot ? mHotColorResId : mSecondaryTextColorResId);
mRankTextView.setText(String.valueOf(item.getRank()));
mScoreTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, hot ? R.drawable.ic_whatshot_orange500_18dp : 0);
mScoreTextView.setText(getContext().getResources().getQuantityString(R.plurals.score, item.getScore(), item.getScore()));
if (item.getKidCount() > 0) {
hot = item.getKidCount() >= hotThreshold;
mCommentButton.setTextColor(hot ? mHotColorResId : mAccentColorResId);
if (hot) {
mCommentButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_whatshot_orange500_24dp, 0, 0, 0);
} else {
mCommentButton.setCompoundDrawablesWithIntrinsicBounds(mCommentDrawable, null, null, null);
}
mCommentButton.setText(String.valueOf(item.getKidCount()));
} else {
mCommentButton.setTextColor(mAccentColorResId);
mCommentButton.setText(null);
mCommentButton.setCompoundDrawablesWithIntrinsicBounds(mCommentDrawable, null, null, null);
}
}
mCommentButton.setVisibility(View.VISIBLE);
mTitleTextView.setText(getContext().getString(R.string.loading_text));
mTitleTextView.setText(story.getDisplayedTitle());
mPostedTextView.setText(story.getDisplayedTime(getContext()));
mPostedTextView.append(story.getDisplayedAuthor(getContext(), false, 0));
switch(story.getType()) {
case Item.JOB_TYPE:
mSourceTextView.setText(null);
mSourceTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_work_white_18dp, 0, 0, 0);
break;
case Item.POLL_TYPE:
mSourceTextView.setText(null);
mSourceTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_poll_white_18dp, 0, 0, 0);
break;
default:
mSourceTextView.setText(story.getSource());
mSourceTextView.setCompoundDrawables(null, null, null, null);
break;
}
}
Aggregations