Merge pull request #2651 from nextcloud/resultOnStoppedAsync

Do not process result of async task if activity is stopped
This commit is contained in:
Mario Đanić 2018-06-05 07:53:09 +02:00 committed by GitHub
commit f123c269f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View file

@ -318,4 +318,11 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
swipeListRefreshLayout.post(() -> swipeListRefreshLayout.setRefreshing(isActive));
}
@Override
protected void onStop() {
super.onStop();
mActionListener.stopLoadingActivity();
}
}

View file

@ -40,5 +40,7 @@ public interface ActivitiesContract {
interface ActionListener {
void loadActivities(String pageUrl);
void openActivity(String fileUrl, BaseActivity baseActivity, boolean isSharingSupported);
void stopLoadingActivity();
}
}

View file

@ -35,6 +35,7 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
private final ActivitiesContract.View activitiesView;
private final ActivitiesRepository activitiesRepository;
private final FilesRepository filesRepository;
private boolean activityStopped = false;
ActivitiesPresenter(@NonNull ActivitiesRepository activitiesRepository,
@ -52,15 +53,20 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
@Override
public void onActivitiesLoaded(List<Object> activities, OwnCloudClient client,
String nextPageUrl) {
if (!activityStopped) {
activitiesView.setProgressIndicatorState(false);
activitiesView.showActivities(activities, client, nextPageUrl);
}
}
@Override
public void onActivitiesLoadedError(String error) {
if (!activityStopped) {
activitiesView.setProgressIndicatorState(false);
activitiesView.showActivitiesLoadError(error);
}
}
});
}
@ -86,4 +92,9 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
}
});
}
@Override
public void stopLoadingActivity() {
activityStopped = true;
}
}