mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 02:17:43 +03:00
Merge pull request #2651 from nextcloud/resultOnStoppedAsync
Do not process result of async task if activity is stopped
This commit is contained in:
commit
f123c269f0
3 changed files with 24 additions and 4 deletions
|
@ -318,4 +318,11 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
|||
swipeListRefreshLayout.post(() -> swipeListRefreshLayout.setRefreshing(isActive));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
mActionListener.stopLoadingActivity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,5 +40,7 @@ public interface ActivitiesContract {
|
|||
interface ActionListener {
|
||||
void loadActivities(String pageUrl);
|
||||
void openActivity(String fileUrl, BaseActivity baseActivity, boolean isSharingSupported);
|
||||
|
||||
void stopLoadingActivity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue