fixed closedBy and closedAt where they are not displayed properly.

This commit is contained in:
Kosh 2017-03-02 22:52:14 +08:00
parent e91db388b6
commit d7562f9511
2 changed files with 12 additions and 5 deletions

View File

@ -44,9 +44,7 @@ public class IssuesViewHolder extends BaseViewHolder<IssueModel> {
? issueModel.getCreatedAt() : issueModel.getClosedAt());
details.setText(SpannableBuilder.builder()
.append(itemView.getResources().getString(issueModel.getState().getStatus()))
.append(" ").append(by).append(" ")
.append(issueModel.getState() == IssueState.closed
? issueModel.getClosedBy().getLogin() : issueModel.getUser().getLogin()).append(" ")
.append(" ")
.append(data));
}
if (withAvatar) {

View File

@ -181,9 +181,18 @@ public class IssuePagerView extends BaseActivity<IssuePagerMvp.View, IssuePagerP
title.setText(issueModel.getTitle());
if (userModel != null) {
size.setVisibility(View.GONE);
String username;
CharSequence parsedDate;
if (issueModel.getState() == IssueState.closed) {
username = issueModel.getClosedBy() != null ? issueModel.getClosedBy().getLogin() : "N/A";
parsedDate = issueModel.getClosedAt() != null ? ParseDateFormat.getTimeAgo(issueModel.getClosedAt()) : "N/A";
} else {
parsedDate = ParseDateFormat.getTimeAgo(issueModel.getCreatedAt());
username = issueModel.getUser() != null ? issueModel.getUser().getLogin() : "N/A";
}
date.setText(SpannableBuilder.builder().append(getString(issueModel.getState().getStatus()))
.append(" ").append(getString(R.string.by)).append(" ").append(userModel.getLogin()).append(" ")
.append(ParseDateFormat.getTimeAgo(issueModel.getCreatedAt())));
.append(" ").append(getString(R.string.by)).append(" ").append(username).append(" ")
.append(parsedDate));
avatarLayout.setUrl(userModel.getAvatarUrl(), userModel.getLogin());
}
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForIssues(this, issueModel)));