Fixed IllegalStateExceptions in some Fragments
This commit is contained in:
parent
aca79dc5b9
commit
c1fbc59f1c
|
@ -68,6 +68,7 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||||
listAdapter = null;
|
listAdapter = null;
|
||||||
viewCreated = false;
|
viewCreated = false;
|
||||||
feedItemDialog = null;
|
feedItemDialog = null;
|
||||||
|
stopItemLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,6 +104,7 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||||
listAdapter = new DownloadedEpisodesListAdapter(getActivity(), itemAccess);
|
listAdapter = new DownloadedEpisodesListAdapter(getActivity(), itemAccess);
|
||||||
setListAdapter(listAdapter);
|
setListAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
|
setListShown(true);
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
if (feedItemDialog != null) {
|
if (feedItemDialog != null) {
|
||||||
boolean res = feedItemDialog.updateContent(queue, items);
|
boolean res = feedItemDialog.updateContent(queue, items);
|
||||||
|
@ -171,7 +173,6 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Object[] results) {
|
protected void onPostExecute(Object[] results) {
|
||||||
super.onPostExecute(results);
|
super.onPostExecute(results);
|
||||||
setListShown(true);
|
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
items = (List<FeedItem>) results[0];
|
items = (List<FeedItem>) results[0];
|
||||||
queue = (QueueAccess) results[1];
|
queue = (QueueAccess) results[1];
|
||||||
|
|
|
@ -11,18 +11,18 @@ import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
import de.danoeh.antennapod.fragment.SearchFragment;
|
|
||||||
import de.danoeh.antennapod.gpoddernet.GpodnetService;
|
import de.danoeh.antennapod.gpoddernet.GpodnetService;
|
||||||
import de.danoeh.antennapod.gpoddernet.GpodnetServiceException;
|
import de.danoeh.antennapod.gpoddernet.GpodnetServiceException;
|
||||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetTag;
|
import de.danoeh.antennapod.gpoddernet.model.GpodnetTag;
|
||||||
import de.danoeh.antennapod.util.menuhandler.MenuItemUtils;
|
import de.danoeh.antennapod.util.menuhandler.MenuItemUtils;
|
||||||
import de.danoeh.antennapod.util.menuhandler.NavDrawerActivity;
|
import de.danoeh.antennapod.util.menuhandler.NavDrawerActivity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TagListFragment extends ListFragment {
|
public class TagListFragment extends ListFragment {
|
||||||
private static final String TAG = "TagListFragment";
|
private static final String TAG = "TagListFragment";
|
||||||
private static final int COUNT = 50;
|
private static final int COUNT = 50;
|
||||||
|
@ -69,11 +69,26 @@ public class TagListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
loadData();
|
startLoadTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadData() {
|
@Override
|
||||||
AsyncTask<Void, Void, List<GpodnetTag>> task = new AsyncTask<Void, Void, List<GpodnetTag>>() {
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
cancelLoadTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
private AsyncTask<Void, Void, List<GpodnetTag>> loadTask;
|
||||||
|
|
||||||
|
private void cancelLoadTask() {
|
||||||
|
if (loadTask != null && !loadTask.isCancelled()) {
|
||||||
|
loadTask.cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startLoadTask() {
|
||||||
|
cancelLoadTask();
|
||||||
|
loadTask = new AsyncTask<Void, Void, List<GpodnetTag>>() {
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,9 +133,9 @@ public class TagListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
} else {
|
} else {
|
||||||
task.execute();
|
loadTask.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue