From adcce2b94fce20fa1ad32cd63ce40786ad5f90b1 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 15 Nov 2019 16:46:26 +0100 Subject: [PATCH] Fixed displaying wrong menu --- .../de/danoeh/antennapod/fragment/ItemPagerFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java index e6cdc5e26..98cb93e7a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java @@ -79,6 +79,8 @@ public class ItemPagerFragment extends Fragment { ViewPager pager = layout.findViewById(R.id.pager); pager.setAdapter(new ItemPagerAdapter()); + pager.setCurrentItem(feedItemPos); + loadItem(feedItems[feedItemPos]); pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { @@ -87,7 +89,7 @@ public class ItemPagerFragment extends Fragment { @Override public void onPageSelected(int position) { - loadItem(position); + loadItem(feedItems[position]); } @Override @@ -95,7 +97,6 @@ public class ItemPagerFragment extends Fragment { } }); - pager.setCurrentItem(feedItemPos); return layout; } @@ -108,12 +109,12 @@ public class ItemPagerFragment extends Fragment { } } - private void loadItem(int position) { + private void loadItem(long itemId) { if (disposable != null) { disposable.dispose(); } - disposable = Observable.fromCallable(() -> DBReader.getFeedItem(position)) + disposable = Observable.fromCallable(() -> DBReader.getFeedItem(itemId)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> {