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