Minor changes to playback history

This commit is contained in:
Martin Fietz 2015-11-30 18:52:06 +01:00
parent 6eca85b409
commit 2ad94d582e
1 changed files with 6 additions and 10 deletions

View File

@ -1,6 +1,6 @@
package de.danoeh.antennapod.fragment; package de.danoeh.antennapod.fragment;
import android.app.Activity; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
@ -14,7 +14,6 @@ import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.MainActivity;
@ -50,16 +49,13 @@ public class PlaybackHistoryFragment extends ListFragment {
private boolean itemsLoaded = false; private boolean itemsLoaded = false;
private boolean viewsCreated = false; private boolean viewsCreated = false;
private AtomicReference<Activity> activity = new AtomicReference<Activity>();
private List<Downloader> downloaderList; private List<Downloader> downloaderList;
private Subscription subscription; private Subscription subscription;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Context context) {
super.onAttach(activity); super.onAttach(context);
this.activity.set(activity);
if (viewsCreated && itemsLoaded) { if (viewsCreated && itemsLoaded) {
onFragmentLoaded(); onFragmentLoaded();
} }
@ -123,7 +119,6 @@ public class PlaybackHistoryFragment extends ListFragment {
if(subscription != null) { if(subscription != null) {
subscription.unsubscribe(); subscription.unsubscribe();
} }
activity.set(null);
} }
@Override @Override
@ -138,7 +133,7 @@ public class PlaybackHistoryFragment extends ListFragment {
DownloaderUpdate update = event.update; DownloaderUpdate update = event.update;
downloaderList = update.downloaders; downloaderList = update.downloaders;
if (adapter != null) { if (adapter != null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
} }
@ -210,7 +205,8 @@ public class PlaybackHistoryFragment extends ListFragment {
// played items shoudln't be transparent for this fragment since, *all* items // played items shoudln't be transparent for this fragment since, *all* items
// in this fragment will, by definition, be played. So it serves no purpose and can make // in this fragment will, by definition, be played. So it serves no purpose and can make
// it harder to read. // it harder to read.
adapter = new FeedItemlistAdapter(getActivity(), itemAccess, new DefaultActionButtonCallback(activity.get()), true, false); adapter = new FeedItemlistAdapter(getActivity(), itemAccess,
new DefaultActionButtonCallback(getActivity()), true, false);
setListAdapter(adapter); setListAdapter(adapter);
} }
setListShown(true); setListShown(true);