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 {
|
||||
protected Status mainStatus, updatedStatus;
|
||||
private final HashMap<String, NeighborAncestryInfo> ancestryMap = new HashMap<>();
|
||||
protected boolean contextInitiallyRendered;
|
||||
private StatusContext result;
|
||||
protected boolean contextInitiallyRendered, transitionFinished;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
@@ -113,6 +114,12 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionFinished() {
|
||||
transitionFinished = true;
|
||||
maybeApplyContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLoadData(int offset, int count){
|
||||
if (refreshing) loadMainStatus();
|
||||
@@ -120,7 +127,32 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
||||
.setCallback(new SimpleCallback<>(this){
|
||||
@Override
|
||||
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;
|
||||
if(refreshing){
|
||||
oldData = new HashMap<>(data.size());
|
||||
@@ -186,26 +218,8 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
|
||||
// for the case that the main status has already finished loading
|
||||
maybeApplyMainStatus();
|
||||
}
|
||||
}
|
||||
})
|
||||
.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);
|
||||
result = null;
|
||||
}
|
||||
|
||||
protected Object maybeApplyMainStatus() {
|
||||
|
||||
Reference in New Issue
Block a user