refactor ancestry, fix case regarding reply line
fix case where reply line was removed despite having no direct ancestor
This commit is contained in:
parent
e04fd8a004
commit
fb8764bcd7
|
@ -357,10 +357,10 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||
if (firstIndex < 0) firstIndex = i;
|
||||
lastIndex = i;
|
||||
StatusDisplayItem item = h.getItem();
|
||||
hasDescendant = item.hasDescendantNeighbor();
|
||||
hasDescendant = item.hasDescendantNeighbor;
|
||||
// no for direct descendants because main status (right above) is
|
||||
// being displayed with an extended footer - no connected layout
|
||||
hasAncestor = item.hasAncestoringNeighbor() && !item.isDirectDescendant;
|
||||
hasAncestor = item.hasAncestoringNeighbor && !item.isDirectDescendant;
|
||||
list.getDecoratedBoundsWithMargins(child, tmpRect);
|
||||
outRect.left=Math.min(outRect.left, tmpRect.left);
|
||||
outRect.top=Math.min(outRect.top, tmpRect.top);
|
||||
|
@ -797,7 +797,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||
RecyclerView.ViewHolder siblingHolder=parent.getChildViewHolder(bottomSibling);
|
||||
if(holder instanceof StatusDisplayItem.Holder<?> ih && siblingHolder instanceof StatusDisplayItem.Holder<?> sh
|
||||
&& (!ih.getItemID().equals(sh.getItemID()) || sh instanceof ExtendedFooterStatusDisplayItem.Holder) && ih.getItem().getType()!=StatusDisplayItem.Type.GAP){
|
||||
if (!ih.getItem().isMainStatus && ih.getItem().hasDescendantNeighbor()) continue;
|
||||
if (!ih.getItem().isMainStatus && ih.getItem().hasDescendantNeighbor) continue;
|
||||
drawDivider(child, bottomSibling, holder, siblingHolder, parent, c, dividerPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||
NeighborAncestryInfo ancestryInfo = ancestryMap.get(s.id);
|
||||
if (ancestryInfo != null) {
|
||||
item.setAncestryInfo(
|
||||
ancestryInfo,
|
||||
ancestryInfo.hasDescendantNeighbor(),
|
||||
ancestryInfo.hasAncestoringNeighbor(),
|
||||
s.id.equals(mainStatus.id),
|
||||
ancestryInfo.getAncestoringNeighbor()
|
||||
.map(ancestor -> ancestor.id.equals(mainStatus.id))
|
||||
|
@ -100,7 +101,8 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||
);
|
||||
}
|
||||
|
||||
if (item instanceof ReblogOrReplyLineStatusDisplayItem && !item.isDirectDescendant) {
|
||||
if (item instanceof ReblogOrReplyLineStatusDisplayItem &&
|
||||
(!item.isDirectDescendant && item.hasAncestoringNeighbor)) {
|
||||
deleteTheseItems.add(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||
bindButton(favorite, item.status.favouritesCount);
|
||||
// in thread view, direct descendant posts display one direct reply to themselves,
|
||||
// hence in that case displaying whether there is another reply
|
||||
int compareTo = item.isMainStatus || !item.hasDescendantNeighbor() ? 0 : 1;
|
||||
int compareTo = item.isMainStatus || !item.hasDescendantNeighbor ? 0 : 1;
|
||||
reply.setSelected(item.status.repliesCount > compareTo);
|
||||
boost.setSelected(item.status.reblogged);
|
||||
favorite.setSelected(item.status.favourited);
|
||||
|
@ -147,7 +147,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||
int nextPos = getAbsoluteAdapterPosition() + 1;
|
||||
boolean nextIsWarning = item.parentFragment.getDisplayItems().size() > nextPos &&
|
||||
item.parentFragment.getDisplayItems().get(nextPos) instanceof WarningFilteredStatusDisplayItem;
|
||||
boolean condenseBottom = !item.isMainStatus && item.hasDescendantNeighbor() &&
|
||||
boolean condenseBottom = !item.isMainStatus && item.hasDescendantNeighbor &&
|
||||
!nextIsWarning;
|
||||
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) itemView.getLayoutParams();
|
||||
|
|
|
@ -47,29 +47,20 @@ public abstract class StatusDisplayItem{
|
|||
public final BaseStatusListFragment parentFragment;
|
||||
public boolean inset;
|
||||
public int index;
|
||||
private ThreadFragment.NeighborAncestryInfo ancestryInfo;
|
||||
public boolean
|
||||
hasDescendantNeighbor = false,
|
||||
hasAncestoringNeighbor = false,
|
||||
isMainStatus = true,
|
||||
isDirectDescendant = false;
|
||||
|
||||
public boolean hasDescendantNeighbor() {
|
||||
return Optional.ofNullable(ancestryInfo)
|
||||
.map(ThreadFragment.NeighborAncestryInfo::hasDescendantNeighbor)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
public boolean hasAncestoringNeighbor() {
|
||||
return Optional.ofNullable(ancestryInfo)
|
||||
.map(ThreadFragment.NeighborAncestryInfo::hasAncestoringNeighbor)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
public void setAncestryInfo(
|
||||
ThreadFragment.NeighborAncestryInfo ancestryInfo,
|
||||
boolean hasDescendantNeighbor,
|
||||
boolean hasAncestoringNeighbor,
|
||||
boolean isMainStatus,
|
||||
boolean isDirectDescendant
|
||||
) {
|
||||
this.ancestryInfo = ancestryInfo;
|
||||
this.hasDescendantNeighbor = hasDescendantNeighbor;
|
||||
this.hasAncestoringNeighbor = hasAncestoringNeighbor;
|
||||
this.isMainStatus = isMainStatus;
|
||||
this.isDirectDescendant = isDirectDescendant;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue