reimplement thread ancestry
This commit is contained in:
@@ -136,16 +136,23 @@ 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
|
||||
reply.setSelected(item.status.repliesCount > (item.descendantLevel > 0 ? 1 : 0));
|
||||
int compareTo = item.isMainStatus || !item.hasDescendantNeighbor() ? 0 : 1;
|
||||
reply.setSelected(item.status.repliesCount > compareTo);
|
||||
boost.setSelected(item.status.reblogged);
|
||||
favorite.setSelected(item.status.favourited);
|
||||
bookmark.setSelected(item.status.bookmarked);
|
||||
boost.setEnabled(item.status.visibility==StatusPrivacy.PUBLIC || item.status.visibility==StatusPrivacy.UNLISTED || item.status.visibility==StatusPrivacy.LOCAL
|
||||
|| (item.status.visibility==StatusPrivacy.PRIVATE && item.status.account.id.equals(AccountSessionManager.getInstance().getAccount(item.accountID).self.id)));
|
||||
|
||||
int nextPos = getAbsoluteAdapterPosition() + 1;
|
||||
boolean nextIsWarning = item.parentFragment.getDisplayItems().size() > nextPos &&
|
||||
item.parentFragment.getDisplayItems().get(nextPos) instanceof WarningFilteredStatusDisplayItem;
|
||||
boolean condenseBottom = !item.isMainStatus && item.hasDescendantNeighbor() &&
|
||||
!nextIsWarning;
|
||||
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) itemView.getLayoutParams();
|
||||
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin,
|
||||
item.descendantLevel != 0 && item.hasDescendantSibling ? V.dp(-6) : 0);
|
||||
condenseBottom ? V.dp(-8) : 0);
|
||||
|
||||
itemView.requestLayout();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.view.ViewGroup;
|
||||
|
||||
import org.joinmastodon.android.GlobalUserPreferences;
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.api.session.AccountSession;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
import org.joinmastodon.android.fragments.HashtagTimelineFragment;
|
||||
@@ -22,7 +21,6 @@ import org.joinmastodon.android.model.Account;
|
||||
import org.joinmastodon.android.model.Attachment;
|
||||
import org.joinmastodon.android.model.DisplayItemsParent;
|
||||
import org.joinmastodon.android.model.Filter;
|
||||
import org.joinmastodon.android.model.Instance;
|
||||
import org.joinmastodon.android.model.Notification;
|
||||
import org.joinmastodon.android.model.Poll;
|
||||
import org.joinmastodon.android.model.ScheduledStatus;
|
||||
@@ -49,8 +47,32 @@ public abstract class StatusDisplayItem{
|
||||
public final BaseStatusListFragment parentFragment;
|
||||
public boolean inset;
|
||||
public int index;
|
||||
public int descendantLevel;
|
||||
public boolean hasDescendantSibling, isDescendantSibling;
|
||||
private ThreadFragment.NeighborAncestryInfo ancestryInfo;
|
||||
public boolean
|
||||
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 isMainStatus,
|
||||
boolean isDirectDescendant
|
||||
) {
|
||||
this.ancestryInfo = ancestryInfo;
|
||||
this.isMainStatus = isMainStatus;
|
||||
this.isDirectDescendant = isDirectDescendant;
|
||||
}
|
||||
|
||||
public StatusDisplayItem(String parentID, BaseStatusListFragment parentFragment){
|
||||
this.parentID=parentID;
|
||||
|
||||
Reference in New Issue
Block a user