Commit 3269a45f authored by Hussein's avatar Hussein

P4A-1120 - Check if fragment is attached in OnGlobalLayoutListener

This reverts (undo rever) commit 77767114.
parent db59131f
......@@ -797,17 +797,7 @@ public class MessageListFragment extends PEpFragment implements ConfirmationDial
super.onResume();
showLoadingMessages();
if(folderName == null) {
loadingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if(!LoaderManager.getInstance(MessageListFragment.this).hasRunningLoaders() && !anyAccountWasDeleted()) {
initializeLoaders();
}
loadingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
startGlobalLayoutListener();
// Check if we have connectivity. Cache the value.
if (hasConnectivity == null) {
......@@ -849,6 +839,23 @@ public class MessageListFragment extends PEpFragment implements ConfirmationDial
}
}
private void startGlobalLayoutListener() {
if (folderName == null) {
loadingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (loadingView.getViewTreeObserver().isAlive()) {
loadingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
if (isAdded() && !anyAccountWasDeleted() &&
!LoaderManager.getInstance(MessageListFragment.this).hasRunningLoaders()) {
initializeLoaders();
}
}
});
}
}
private void restartLoader() {
if (cursorValid == null) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment