Merge pull request #7210 from nextcloud/populateList

Only do UI manipulation if visible
This commit is contained in:
Andy Scherzinger 2020-11-03 18:11:57 +01:00 committed by GitHub
commit 74edac558a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,6 +77,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@ -364,7 +365,9 @@ public class FileDetailActivitiesFragment extends Fragment implements
}
activity.runOnUiThread(() -> {
populateList(activitiesAndVersions, lastGiven == -1);
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
populateList(activitiesAndVersions, lastGiven == -1);
}
});
} else {
Log_OC.d(TAG, result.getLogMessage());
@ -375,8 +378,10 @@ public class FileDetailActivitiesFragment extends Fragment implements
}
final String finalLogMessage = logMessage;
activity.runOnUiThread(() -> {
setErrorContent(finalLogMessage);
isLoadingActivities = false;
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
setErrorContent(finalLogMessage);
isLoadingActivities = false;
}
});
}
@ -451,13 +456,15 @@ public class FileDetailActivitiesFragment extends Fragment implements
private void hideRefreshLayoutLoader(FragmentActivity activity) {
activity.runOnUiThread(() -> {
if (swipeListRefreshLayout != null) {
swipeListRefreshLayout.setRefreshing(false);
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (swipeListRefreshLayout != null) {
swipeListRefreshLayout.setRefreshing(false);
}
if (swipeEmptyListRefreshLayout != null) {
swipeEmptyListRefreshLayout.setRefreshing(false);
}
isLoadingActivities = false;
}
if (swipeEmptyListRefreshLayout != null) {
swipeEmptyListRefreshLayout.setRefreshing(false);
}
isLoadingActivities = false;
});
}