Fix deleted milestone crash in timeline view (#1242)

Closes #1241

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1242
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
M M Arif 2023-02-03 07:34:48 +00:00
parent 06a7eb5a0c
commit 77d84dfefe
2 changed files with 19 additions and 10 deletions

View File

@ -462,9 +462,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
this.issueComment = timelineComment;
if (timelineLastView) {
// timelineLine2.setVisibility(View.GONE);
}
// if (timelineLastView) {
// timelineLine2.setVisibility(View.GONE);
// }
StringBuilder infoBuilder = null;
if (issueComment.getCreatedAt() != null) {
@ -485,6 +485,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
.append(context.getString(R.string.modifiedText));
}
}
assert infoBuilder != null;
String info = infoBuilder.toString();
// label view in timeline
@ -701,17 +702,24 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
issueComment.getMilestone().getTitle(),
info));
} else {
start.setText(
context.getString(
R.string.timelineMilestoneRemoved,
issueComment.getUser().getLogin(),
issueComment.getOldMilestone().getTitle(),
info));
if (issueComment.getOldMilestone() != null) {
start.setText(
context.getString(
R.string.timelineMilestoneRemoved,
issueComment.getUser().getLogin(),
issueComment.getOldMilestone().getTitle(),
info));
} else {
start.setText(
context.getString(
R.string.timelineMilestoneDeleted,
issueComment.getUser().getLogin(),
info));
}
timelineIcon.setColorFilter(
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
}
start.setTextSize(fontSize);
timelineIcon.setImageDrawable(
ContextCompat.getDrawable(context, R.drawable.ic_milestone));
timelineData.addView(start);

View File

@ -814,6 +814,7 @@
<string name="timelineAssigneesAssigned">%1$s was assigned by %2$s %3$s</string>
<string name="timelineMilestoneAdded">%1$s added this to the %2$s milestone %3$s</string>
<string name="timelineMilestoneRemoved">%1$s removed this from the %2$s milestone %3$s</string>
<string name="timelineMilestoneDeleted">%1$s added this to a deleted milestone %2$s</string>
<string name="timelineStatusClosedIssue">%1$s closed this issue %2$s</string>
<string name="timelineStatusReopenedIssue">%1$s reopened this issue %2$s</string>
<string name="timelineStatusReopenedPr">%1$s reopened this pull request %2$s</string>