don't display context until fragment transition finished
This commit is contained in:
@@ -52,7 +52,8 @@ import me.grishka.appkit.utils.V;
|
|||||||
public class ThreadFragment extends StatusListFragment implements ProvidesAssistContent {
|
public class ThreadFragment extends StatusListFragment implements ProvidesAssistContent {
|
||||||
protected Status mainStatus, updatedStatus;
|
protected Status mainStatus, updatedStatus;
|
||||||
private final HashMap<String, NeighborAncestryInfo> ancestryMap = new HashMap<>();
|
private final HashMap<String, NeighborAncestryInfo> ancestryMap = new HashMap<>();
|
||||||
protected boolean contextInitiallyRendered;
|
private StatusContext result;
|
||||||
|
protected boolean contextInitiallyRendered, transitionFinished;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -113,6 +114,12 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTransitionFinished() {
|
||||||
|
transitionFinished = true;
|
||||||
|
maybeApplyContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
if (refreshing) loadMainStatus();
|
if (refreshing) loadMainStatus();
|
||||||
@@ -120,7 +127,32 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||||||
.setCallback(new SimpleCallback<>(this){
|
.setCallback(new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(StatusContext result){
|
public void onSuccess(StatusContext result){
|
||||||
if (getContext() == null) return;
|
ThreadFragment.this.result = result;
|
||||||
|
maybeApplyContext();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec(accountID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadMainStatus() {
|
||||||
|
new GetStatusByID(mainStatus.id)
|
||||||
|
.setCallback(new Callback<>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Status status) {
|
||||||
|
if (getContext() == null || status == null) return;
|
||||||
|
updatedStatus = status;
|
||||||
|
// for the case that the context has already loaded (and the animation has
|
||||||
|
// already finished), falling back to applying it ourselves:
|
||||||
|
maybeApplyMainStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error) {}
|
||||||
|
}).exec(accountID);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void maybeApplyContext() {
|
||||||
|
if (!transitionFinished || result == null || getContext() == null) return;
|
||||||
Map<String, Status> oldData = null;
|
Map<String, Status> oldData = null;
|
||||||
if(refreshing){
|
if(refreshing){
|
||||||
oldData = new HashMap<>(data.size());
|
oldData = new HashMap<>(data.size());
|
||||||
@@ -133,7 +165,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out how this code works
|
// TODO: figure out how this code works
|
||||||
if(isInstanceAkkoma()) sortStatusContext(mainStatus, result);
|
if (isInstanceAkkoma()) sortStatusContext(mainStatus, result);
|
||||||
|
|
||||||
result.descendants=filterStatuses(result.descendants);
|
result.descendants=filterStatuses(result.descendants);
|
||||||
result.ancestors=filterStatuses(result.ancestors);
|
result.ancestors=filterStatuses(result.ancestors);
|
||||||
@@ -186,26 +218,8 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
|||||||
// for the case that the main status has already finished loading
|
// for the case that the main status has already finished loading
|
||||||
maybeApplyMainStatus();
|
maybeApplyMainStatus();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadMainStatus() {
|
result = null;
|
||||||
new GetStatusByID(mainStatus.id)
|
|
||||||
.setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Status status) {
|
|
||||||
if (getContext() == null || status == null) return;
|
|
||||||
updatedStatus = status;
|
|
||||||
// for the case that the context has already loaded (and the animation has
|
|
||||||
// already finished), falling back to applying it ourselves:
|
|
||||||
maybeApplyMainStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {}
|
|
||||||
}).exec(accountID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object maybeApplyMainStatus() {
|
protected Object maybeApplyMainStatus() {
|
||||||
|
|||||||
Reference in New Issue
Block a user