From 4e2f9af198f2dd26fb25e60edd52d8defb7bde1e Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 2 Sep 2019 11:46:16 +0200 Subject: [PATCH] fix endless scroll on file detail activity stream Signed-off-by: tobiasKaminsky --- .../ui/fragment/FileDetailActivitiesFragment.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java index 6ecdc66d98..27ca327741 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java @@ -99,6 +99,7 @@ public class FileDetailActivitiesFragment extends Fragment implements private static final String ARG_FILE = "FILE"; private static final String ARG_ACCOUNT = "ACCOUNT"; + private static final int END_REACHED = 0; private ActivityAndVersionListAdapter adapter; private Unbinder unbinder; @@ -311,9 +312,9 @@ public class FileDetailActivitiesFragment extends Fragment implements GetActivitiesRemoteOperation getRemoteNotificationOperation; if (lastGiven > 0) { - getRemoteNotificationOperation = new GetActivitiesRemoteOperation(file.getLocalId()); - } else { getRemoteNotificationOperation = new GetActivitiesRemoteOperation(file.getLocalId(), lastGiven); + } else { + getRemoteNotificationOperation = new GetActivitiesRemoteOperation(file.getLocalId()); } Log_OC.d(TAG, "BEFORE getRemoteActivitiesOperation.execute"); @@ -333,14 +334,19 @@ public class FileDetailActivitiesFragment extends Fragment implements final List data = result.getData(); final List activitiesAndVersions = (ArrayList) data.get(0); + this.lastGiven = (int) data.get(1); + + if (activitiesAndVersions.isEmpty()) { + this.lastGiven = END_REACHED; + } + if (restoreFileVersionSupported && versions != null) { activitiesAndVersions.addAll(versions); } - this.lastGiven = (int) data.get(1); activity.runOnUiThread(() -> { populateList(activitiesAndVersions, lastGiven == -1); - if (activitiesAndVersions.isEmpty()) { + if (adapter.getItemCount() == 0) { setEmptyContent(noResultsHeadline, noResultsMessage); list.setVisibility(View.GONE); empty.setVisibility(View.VISIBLE);