Merge pull request #3812 from ByteHamster/invalidate-pager-menu
Invalidate ItemPager menu on update
This commit is contained in:
commit
3f87fbd88d
@ -16,6 +16,7 @@ import androidx.viewpager.widget.ViewPager;
|
|||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.CastEnabledActivity;
|
import de.danoeh.antennapod.activity.CastEnabledActivity;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
|
import de.danoeh.antennapod.core.event.FeedItemEvent;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.util.Flavors;
|
import de.danoeh.antennapod.core.util.Flavors;
|
||||||
@ -24,6 +25,9 @@ import io.reactivex.Observable;
|
|||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays information about a list of FeedItems.
|
* Displays information about a list of FeedItems.
|
||||||
@ -104,12 +108,14 @@ public class ItemPagerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
if (disposable != null) {
|
if (disposable != null) {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
@ -167,6 +173,17 @@ public class ItemPagerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onEventMainThread(FeedItemEvent event) {
|
||||||
|
for (FeedItem item : event.items) {
|
||||||
|
if (this.item != null && this.item.getId() == item.getId()) {
|
||||||
|
this.item = item;
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void openPodcast() {
|
private void openPodcast() {
|
||||||
Fragment fragment = FeedItemlistFragment.newInstance(item.getFeedId());
|
Fragment fragment = FeedItemlistFragment.newInstance(item.getFeedId());
|
||||||
((MainActivity) getActivity()).loadChildFragment(fragment);
|
((MainActivity) getActivity()).loadChildFragment(fragment);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user