mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 18:28:59 +03:00
check for nullable context
stop task on pause Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
572d63e428
commit
5a53ca3c7c
2 changed files with 21 additions and 6 deletions
|
@ -87,7 +87,11 @@ public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult
|
||||||
searchRemoteOperation.setLimit(limit);
|
searchRemoteOperation.setLimit(limit);
|
||||||
searchRemoteOperation.setTimestamp(timestamp);
|
searchRemoteOperation.setTimestamp(timestamp);
|
||||||
|
|
||||||
return searchRemoteOperation.execute(account, photoFragment.requireContext());
|
if (photoFragment.getContext() != null) {
|
||||||
|
return searchRemoteOperation.execute(account, photoFragment.getContext());
|
||||||
|
} else {
|
||||||
|
return new RemoteOperationResult(new IllegalStateException("No context available"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
package com.owncloud.android.ui.fragment;
|
package com.owncloud.android.ui.fragment;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -50,12 +51,22 @@ public class PhotoFragment extends OCFileListFragment {
|
||||||
private boolean photoSearchQueryRunning = false;
|
private boolean photoSearchQueryRunning = false;
|
||||||
private boolean photoSearchNoNew = false;
|
private boolean photoSearchNoNew = false;
|
||||||
private SearchRemoteOperation searchRemoteOperation;
|
private SearchRemoteOperation searchRemoteOperation;
|
||||||
|
private AsyncTask photoSearchTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
if (photoSearchTask != null) {
|
||||||
|
photoSearchTask.cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -138,11 +149,11 @@ public class PhotoFragment extends OCFileListFragment {
|
||||||
|
|
||||||
private void searchAndDisplay() {
|
private void searchAndDisplay() {
|
||||||
if (!photoSearchQueryRunning && !photoSearchNoNew) {
|
if (!photoSearchQueryRunning && !photoSearchNoNew) {
|
||||||
new PhotoSearchTask(getColumnsCount(),
|
photoSearchTask = new PhotoSearchTask(getColumnsCount(),
|
||||||
this,
|
this,
|
||||||
accountManager.getCurrentAccount(),
|
accountManager.getCurrentAccount(),
|
||||||
searchRemoteOperation,
|
searchRemoteOperation,
|
||||||
mContainerActivity.getStorageManager())
|
mContainerActivity.getStorageManager())
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue