mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add onDestroy() and check for isCancelled()
This commit is contained in:
parent
5cdf3a6bab
commit
df11e65806
2 changed files with 15 additions and 0 deletions
|
|
@ -109,6 +109,15 @@ public class NearbyListFragment extends ListFragment implements TaskListener {
|
|||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if(nearbyAsyncTask != null && nearbyAsyncTask.getStatus() != AsyncTask.Status.FINISHED) {
|
||||
nearbyAsyncTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
private class NearbyAsyncTask extends AsyncTask<Void, Integer, List<Place>> {
|
||||
|
||||
private final TaskListener listener;
|
||||
|
|
@ -138,6 +147,11 @@ public class NearbyListFragment extends ListFragment implements TaskListener {
|
|||
@Override
|
||||
protected void onPostExecute(List<Place> result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
if(isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
mAdapter = new NearbyAdapter(getActivity(), places);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class NearbyPlaces {
|
|||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
|
||||
URL file = new URL("https://tools.wmflabs.org/wiki-needs-pictures/data/data.csv");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(file.openStream()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue