Skip to content

Commit

Permalink
Updated naming + comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
khaykov committed Nov 20, 2020
1 parent 94b7de5 commit 593ebad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,23 @@ class ReaderPostUiStateBuilder @Inject constructor(
post: ReaderPost,
onBlogSectionClicked: (Long, Long) -> Unit,
postListType: ReaderPostListType? = null,
showP2SpecificLayout: Boolean = false
) = buildBlogSectionUiState(post, onBlogSectionClicked, postListType, showP2SpecificLayout)
isP2Post: Boolean = false
) = buildBlogSectionUiState(post, onBlogSectionClicked, postListType, isP2Post)

private fun buildBlogSectionUiState(
post: ReaderPost,
onBlogSectionClicked: (Long, Long) -> Unit,
postListType: ReaderPostListType?,
showP2SpecificLayout: Boolean = false
isP2Post: Boolean = false
): ReaderBlogSectionUiState {
return ReaderBlogSectionUiState(
postId = post.postId,
blogId = post.blogId,
blogName = buildBlogName(post, showP2SpecificLayout),
blogName = buildBlogName(post, isP2Post),
blogUrl = buildBlogUrl(post),
dateLine = buildDateLine(post),
avatarOrBlavatarUrl = buildAvatarOrBlavatarUrl(post),
isAuthorAvatarVisible = showP2SpecificLayout,
isAuthorAvatarVisible = isP2Post,
authorAvatarUrl = gravatarUtilsWrapper.fixGravatarUrlWithResource(
post.postAvatar,
R.dimen.avatar_sz_medium
Expand Down Expand Up @@ -312,11 +312,11 @@ class ReaderPostUiStateBuilder @Inject constructor(
private fun buildExcerpt(post: ReaderPost) =
post.takeIf { post.cardType != PHOTO && post.hasExcerpt() }?.excerpt

private fun buildBlogName(post: ReaderPost, showP2SpecificLayout: Boolean = false): UiString {
private fun buildBlogName(post: ReaderPost, isP2Post: Boolean = false): UiString {
val blogName = post.takeIf { it.hasBlogName() }?.blogName?.let { UiStringText(it) }
?: UiStringRes(R.string.untitled_in_parentheses)

if (!showP2SpecificLayout) {
if (!isP2Post) {
return blogName
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class ReaderPostDetailHeaderView @JvmOverloads constructor(

private fun updateBlavatar(state: ReaderBlogSectionUiState) {
uiHelpers.updateVisibility(image_avatar_or_blavatar, state.avatarOrBlavatarUrl != null)
uiHelpers.updateVisibility(authors_avatar, state.isAuthorAvatarVisible)
if (state.avatarOrBlavatarUrl == null) {
imageManager.cancelRequestAndClearImageView(image_avatar_or_blavatar)
} else {
Expand All @@ -87,6 +86,8 @@ class ReaderPostDetailHeaderView @JvmOverloads constructor(
BLAVATAR_CIRCULAR, state.avatarOrBlavatarUrl
)
}
// we don't show the p2 style of header in post details yet
uiHelpers.updateVisibility(authors_avatar, state.isAuthorAvatarVisible)
}

private fun updateFollowButton(followButtonUiState: FollowButtonUiState) {
Expand Down

0 comments on commit 593ebad

Please sign in to comment.