Skip to content

Commit

Permalink
Do not do reply-group auto-selection if there are multiple groups
Browse files Browse the repository at this point in the history
Before this commit auto-selection would kick-in when there were
multiple groups, but only one of them had a reply button. (For other
groups replying was disabled)

Now in that situation we won't do auto-selection and let the user to
manually select the (only) group they want to reply to when they
decide to do so.
  • Loading branch information
Tunous committed Nov 9, 2017
1 parent e61bf93 commit f965427
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/src/main/java/com/gh4a/fragment/ReviewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,23 @@ protected void onAddData(RootAdapter<TimelineItem, ?> adapter, List<TimelineItem
}

private void selectAndRemoveFirstReply(List<TimelineItem> data) {
int replyItemCount = 0;
int groupCount = 0;
TimelineItem.Reply firstReplyItem = null;
TimelineItem.Diff firstDiffItem = null;
for (TimelineItem timelineItem : data) {
if (timelineItem instanceof TimelineItem.Reply) {
replyItemCount += 1;

if (replyItemCount > 1) {
if (timelineItem instanceof TimelineItem.Diff) {
groupCount += 1;
if (groupCount > 1) {
return;
}

if (firstReplyItem == null) {
firstReplyItem = (TimelineItem.Reply) timelineItem;
if (firstDiffItem == null) {
firstDiffItem = (TimelineItem.Diff) timelineItem;
}
} else if (firstDiffItem != null && timelineItem instanceof TimelineItem.Reply) {
TimelineItem.Reply replyItem = (TimelineItem.Reply) timelineItem;
if (replyItem.timelineComment.getParentDiff().equals(firstDiffItem)) {
firstReplyItem = replyItem;
}
}
}
Expand Down

0 comments on commit f965427

Please sign in to comment.