Eventdistributor listener was registered incorrectly

This commit is contained in:
daniel oeh 2013-08-30 21:53:15 +02:00
parent 3c08859517
commit 42a39b3cfc
1 changed files with 13 additions and 12 deletions

View File

@ -60,6 +60,8 @@ public class ItemlistFragment extends ListFragment {
/** Argument for FeeditemlistAdapter */ /** Argument for FeeditemlistAdapter */
protected boolean showFeedtitle; protected boolean showFeedtitle;
private AsyncTask<Long, Void, Feed> currentLoadTask;
public ItemlistFragment(boolean showFeedtitle) { public ItemlistFragment(boolean showFeedtitle) {
super(); super();
this.showFeedtitle = showFeedtitle; this.showFeedtitle = showFeedtitle;
@ -118,9 +120,19 @@ public class ItemlistFragment extends ListFragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
EventDistributor.getInstance().register(contentUpdate);
loadData(); loadData();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
EventDistributor.getInstance().unregister(contentUpdate);
if (currentLoadTask != null) {
currentLoadTask.cancel(true);
}
}
protected void loadData() { protected void loadData() {
final long feedId; final long feedId;
if (feed == null) { if (feed == null) {
@ -168,6 +180,7 @@ public class ItemlistFragment extends ListFragment {
} }
} }
}; };
currentLoadTask = loadTask;
loadTask.execute(feedId); loadTask.execute(feedId);
} }
@ -184,17 +197,6 @@ public class ItemlistFragment extends ListFragment {
adapterCallback, showFeedtitle); adapterCallback, showFeedtitle);
} }
@Override
public void onPause() {
super.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
EventDistributor.getInstance().unregister(contentUpdate);
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -206,7 +208,6 @@ public class ItemlistFragment extends ListFragment {
} }
}); });
updateProgressBarVisibility(); updateProgressBarVisibility();
EventDistributor.getInstance().register(contentUpdate);
} }
@Override @Override