Fixed displaying wrong menu
This commit is contained in:
parent
4336c10fb1
commit
adcce2b94f
|
@ -79,6 +79,8 @@ public class ItemPagerFragment extends Fragment {
|
||||||
|
|
||||||
ViewPager pager = layout.findViewById(R.id.pager);
|
ViewPager pager = layout.findViewById(R.id.pager);
|
||||||
pager.setAdapter(new ItemPagerAdapter());
|
pager.setAdapter(new ItemPagerAdapter());
|
||||||
|
pager.setCurrentItem(feedItemPos);
|
||||||
|
loadItem(feedItems[feedItemPos]);
|
||||||
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
@ -87,7 +89,7 @@ public class ItemPagerFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
loadItem(position);
|
loadItem(feedItems[position]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,7 +97,6 @@ public class ItemPagerFragment extends Fragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pager.setCurrentItem(feedItemPos);
|
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
@ -108,12 +109,12 @@ public class ItemPagerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadItem(int position) {
|
private void loadItem(long itemId) {
|
||||||
if (disposable != null) {
|
if (disposable != null) {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
disposable = Observable.fromCallable(() -> DBReader.getFeedItem(position))
|
disposable = Observable.fromCallable(() -> DBReader.getFeedItem(itemId))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(result -> {
|
.subscribe(result -> {
|
||||||
|
|
Loading…
Reference in New Issue