From 8738032259a3ca7bde8eb97bd1f6840fd03d5b31 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 18 Jul 2014 16:23:55 -0700 Subject: #370 Cancel current load task before starting another --- .../daneren2005/dsub/fragments/SelectDirectoryFragment.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 2191f439..f0497703 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -63,6 +63,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter private List entries; private boolean albumContext = false; private boolean addAlbumHeader = false; + private LoadTask currentTask; String id; String name; @@ -433,6 +434,10 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter refresh = true; } + if(currentTask != null) { + currentTask.cancel(); + } + entryList.setVisibility(View.INVISIBLE); if (playlistId != null) { getPlaylist(playlistId, playlistName, refresh); @@ -599,6 +604,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter public LoadTask() { super(SelectDirectoryFragment.this); + + currentTask = this; } protected abstract MusicDirectory load(MusicService service) throws Exception; @@ -622,6 +629,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } licenseValid = result.getSecond(); finishLoading(); + + currentTask = null; } } -- cgit v1.2.3