mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 18:45:07 +01:00
Fix a leak when rotating screen while reading
This commit is contained in:
parent
e177edfee6
commit
11563e6f95
@ -66,9 +66,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
}
|
||||
|
||||
public void onPageListReady(List<Page> pages) {
|
||||
if (viewer != null)
|
||||
viewer.destroySubscriptions();
|
||||
viewer = getViewer();
|
||||
viewer.onPageListReady(pages);
|
||||
viewer.updatePageNumber();
|
||||
}
|
||||
|
@ -11,16 +11,14 @@ public class ViewPagerReaderAdapter extends SmartFragmentStatePagerAdapter {
|
||||
|
||||
private List<Page> pages;
|
||||
|
||||
public ViewPagerReaderAdapter(FragmentManager fragmentManager) {
|
||||
public ViewPagerReaderAdapter(FragmentManager fragmentManager, List<Page> pages) {
|
||||
super(fragmentManager);
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (pages != null)
|
||||
return pages.size();
|
||||
|
||||
return 0;
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,8 +24,6 @@ public abstract class HorizontalReader extends BaseReader {
|
||||
activity.getLayoutInflater().inflate(R.layout.reader_horizontal, container);
|
||||
ButterKnife.bind(this, container);
|
||||
|
||||
adapter = new ViewPagerReaderAdapter(activity.getSupportFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
viewPager.addOnPageChangeListener(new HorizontalViewPager.SimpleOnPageChangeListener() {
|
||||
@Override
|
||||
@ -60,7 +58,9 @@ public abstract class HorizontalReader extends BaseReader {
|
||||
|
||||
@Override
|
||||
public void onPageListReady(List<Page> pages) {
|
||||
adapter.setPages(pages);
|
||||
currentPosition = 0;
|
||||
adapter = new ViewPagerReaderAdapter(activity.getSupportFragmentManager(), pages);
|
||||
viewPager.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ public class RightToLeftReader extends HorizontalReader {
|
||||
public void onPageListReady(List<Page> pages) {
|
||||
ArrayList<Page> inversedPages = new ArrayList<>(pages);
|
||||
Collections.reverse(inversedPages);
|
||||
adapter.setPages(inversedPages);
|
||||
super.onPageListReady(inversedPages);
|
||||
viewPager.setCurrentItem(adapter.getCount() - 1, false);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@ public class VerticalReader extends BaseReader {
|
||||
activity.getLayoutInflater().inflate(R.layout.reader_vertical, container);
|
||||
ButterKnife.bind(this, container);
|
||||
|
||||
adapter = new ViewPagerReaderAdapter(activity.getSupportFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||
@Override
|
||||
@ -49,7 +47,9 @@ public class VerticalReader extends BaseReader {
|
||||
|
||||
@Override
|
||||
public void onPageListReady(List<Page> pages) {
|
||||
adapter.setPages(pages);
|
||||
currentPosition = 0;
|
||||
adapter = new ViewPagerReaderAdapter(activity.getSupportFragmentManager(), pages);
|
||||
viewPager.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user