diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/RightToLeftViewer.java b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/RightToLeftViewer.java index aab9bee74..c690d8e44 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/RightToLeftViewer.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/RightToLeftViewer.java @@ -21,7 +21,7 @@ public class RightToLeftViewer extends ViewPagerViewer { ArrayList inversedPages = new ArrayList<>(pages); Collections.reverse(inversedPages); adapter.setPages(inversedPages); - viewPager.setCurrentItem(adapter.getCount()-1); + getViewPager().setCurrentItem(adapter.getCount()-1); } @Override diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/VerticalViewer.java b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/VerticalViewer.java index f1c4252b1..4c5b652d1 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/VerticalViewer.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/VerticalViewer.java @@ -5,6 +5,8 @@ import android.widget.FrameLayout; import java.util.List; +import butterknife.Bind; +import butterknife.ButterKnife; import eu.kanade.mangafeed.R; import eu.kanade.mangafeed.data.models.Page; import eu.kanade.mangafeed.ui.activity.ReaderActivity; @@ -15,15 +17,15 @@ import fr.castorflex.android.verticalviewpager.VerticalViewPager; public class VerticalViewer extends BaseViewer { - private VerticalViewPager viewPager; + @Bind(R.id.view_pager) VerticalViewPager viewPager; private ReaderPageAdapter adapter; public VerticalViewer(ReaderActivity activity, FrameLayout container) { super(activity, container); activity.getLayoutInflater().inflate(R.layout.viewer_verticalviewpager, container); + ButterKnife.bind(this, container); adapter = new ReaderPageAdapter(activity.getSupportFragmentManager()); - viewPager = (VerticalViewPager) activity.findViewById(R.id.view_pager); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(3); viewPager.setOnPageChangeListener(new ReaderViewPager.OnPageChangeListener() { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/base/ViewPagerViewer.java b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/base/ViewPagerViewer.java index b74f46f98..34245bbda 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/viewer/base/ViewPagerViewer.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/viewer/base/ViewPagerViewer.java @@ -5,6 +5,8 @@ import android.widget.FrameLayout; import java.util.List; +import butterknife.Bind; +import butterknife.ButterKnife; import eu.kanade.mangafeed.R; import eu.kanade.mangafeed.data.models.Page; import eu.kanade.mangafeed.ui.activity.ReaderActivity; @@ -13,15 +15,15 @@ import eu.kanade.mangafeed.widget.ReaderViewPager; public abstract class ViewPagerViewer extends BaseViewer { - protected ReaderViewPager viewPager; + @Bind(R.id.view_pager) ReaderViewPager viewPager; protected ReaderPageAdapter adapter; public ViewPagerViewer(ReaderActivity activity, FrameLayout container) { super(activity, container); activity.getLayoutInflater().inflate(R.layout.viewer_viewpager, container); + ButterKnife.bind(this, container); adapter = new ReaderPageAdapter(activity.getSupportFragmentManager()); - viewPager = (ReaderViewPager) activity.findViewById(R.id.view_pager); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(3); viewPager.addOnPageChangeListener(new ReaderViewPager.OnPageChangeListener() { @@ -54,6 +56,10 @@ public abstract class ViewPagerViewer extends BaseViewer { }); } + public ReaderViewPager getViewPager() { + return viewPager; + } + @Override public int getTotalPages() { return adapter.getCount(); diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 84787446b..2ce8e16b4 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -2,12 +2,12 @@