mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 15:39:16 +01:00
Fix bug in reader's current position
This commit is contained in:
parent
720b0a29ce
commit
571c24d3d9
@ -83,7 +83,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
source = event.getSource();
|
source = event.getSource();
|
||||||
chapter = event.getChapter();
|
chapter = event.getChapter();
|
||||||
if (chapter.last_page_read != 0)
|
if (chapter.last_page_read != 0)
|
||||||
currentPage = chapter.last_page_read - 1;
|
currentPage = chapter.last_page_read;
|
||||||
|
|
||||||
start(1);
|
start(1);
|
||||||
}
|
}
|
||||||
@ -110,10 +110,9 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveChapter() {
|
private void saveChapter() {
|
||||||
chapter.last_page_read = currentPage + 1;
|
chapter.last_page_read = currentPage;
|
||||||
if (currentPage == pageList.size() - 1) {
|
if (currentPage == pageList.size() - 1) {
|
||||||
chapter.read = true;
|
chapter.read = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
db.insertChapterBlock(chapter);
|
db.insertChapterBlock(chapter);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
@Inject PreferencesHelper prefs;
|
@Inject PreferencesHelper prefs;
|
||||||
|
|
||||||
private BaseViewer viewer;
|
private BaseViewer viewer;
|
||||||
|
private boolean isFullscreen;
|
||||||
|
|
||||||
private static final int LEFT_TO_RIGHT = 1;
|
private static final int LEFT_TO_RIGHT = 1;
|
||||||
private static final int RIGHT_TO_LEFT = 2;
|
private static final int RIGHT_TO_LEFT = 2;
|
||||||
@ -66,15 +67,25 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
|
|
||||||
public void onPageListReady(List<Page> pages) {
|
public void onPageListReady(List<Page> pages) {
|
||||||
viewer.onPageListReady(pages);
|
viewer.onPageListReady(pages);
|
||||||
|
viewer.updatePageNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPageChanged(int currentPageIndex, int totalPages) {
|
public void onPageChanged(int currentPageIndex, int totalPages) {
|
||||||
if (currentPageIndex != 0)
|
|
||||||
getPresenter().setCurrentPage(currentPageIndex);
|
|
||||||
String page = (currentPageIndex + 1) + "/" + totalPages;
|
String page = (currentPageIndex + 1) + "/" + totalPages;
|
||||||
pageNumber.setText(page);
|
pageNumber.setText(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
getPresenter().setCurrentPage(viewer.getCurrentPosition());
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelectedPage(int pageIndex) {
|
public void setSelectedPage(int pageIndex) {
|
||||||
viewer.setSelectedPage(pageIndex);
|
viewer.setSelectedPage(pageIndex);
|
||||||
}
|
}
|
||||||
@ -95,6 +106,22 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
View.SYSTEM_UI_FLAG_LOW_PROFILE
|
View.SYSTEM_UI_FLAG_LOW_PROFILE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
isFullscreen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableFullscreen() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.VISIBLE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
isFullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableHardwareAcceleration() {
|
public void enableHardwareAcceleration() {
|
||||||
@ -103,10 +130,21 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onImageTouch(MotionEvent motionEvent) {
|
public boolean onImageSingleTap(MotionEvent motionEvent) {
|
||||||
return viewer.onImageTouch(motionEvent);
|
return viewer.onImageTouch(motionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCenterSingleTap() {
|
||||||
|
toggleFullscreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleFullscreen() {
|
||||||
|
if (isFullscreen)
|
||||||
|
disableFullscreen();
|
||||||
|
else
|
||||||
|
enableFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
private BaseViewer getViewer() {
|
private BaseViewer getViewer() {
|
||||||
switch (prefs.getDefaultViewer()) {
|
switch (prefs.getDefaultViewer()) {
|
||||||
case LEFT_TO_RIGHT: default:
|
case LEFT_TO_RIGHT: default:
|
||||||
|
@ -59,7 +59,7 @@ public class ReaderPageFragment extends Fragment {
|
|||||||
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
||||||
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
||||||
imageView.setOnTouchListener((v, motionEvent) ->
|
imageView.setOnTouchListener((v, motionEvent) ->
|
||||||
((ReaderActivity) getActivity()).onImageTouch(motionEvent));
|
((ReaderActivity) getActivity()).onImageSingleTap(motionEvent));
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class ChapterListHolder extends ItemViewHolder<Chapter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chapter.last_page_read > 0 && !chapter.read) {
|
if (chapter.last_page_read > 0 && !chapter.read) {
|
||||||
pages.setText(getContext().getString(R.string.chapter_progress, chapter.last_page_read));
|
pages.setText(getContext().getString(R.string.chapter_progress, chapter.last_page_read+1));
|
||||||
} else {
|
} else {
|
||||||
pages.setText("");
|
pages.setText("");
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ public class VerticalViewer extends BaseViewer {
|
|||||||
@Override
|
@Override
|
||||||
public void onPageListReady(List<Page> pages) {
|
public void onPageListReady(List<Page> pages) {
|
||||||
adapter.setPages(pages);
|
adapter.setPages(pages);
|
||||||
updatePageNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,6 +29,10 @@ public abstract class BaseViewer {
|
|||||||
return viewerPosition;
|
return viewerPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentPosition() {
|
||||||
|
return getCurrentPageIndex(currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract int getTotalPages();
|
public abstract int getTotalPages();
|
||||||
public abstract void setSelectedPage(int pageNumber);
|
public abstract void setSelectedPage(int pageNumber);
|
||||||
public abstract void onPageListReady(List<Page> pages);
|
public abstract void onPageListReady(List<Page> pages);
|
||||||
|
@ -54,6 +54,7 @@ public abstract class ViewPagerViewer extends BaseViewer {
|
|||||||
onLastPageOut();
|
onLastPageOut();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
viewPager.setOnChapterSingleTapListener(activity::onCenterSingleTap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReaderViewPager getViewPager() {
|
public ReaderViewPager getViewPager() {
|
||||||
@ -73,7 +74,6 @@ public abstract class ViewPagerViewer extends BaseViewer {
|
|||||||
@Override
|
@Override
|
||||||
public void onPageListReady(List<Page> pages) {
|
public void onPageListReady(List<Page> pages) {
|
||||||
adapter.setPages(pages);
|
adapter.setPages(pages);
|
||||||
updatePageNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,6 +125,10 @@ public class ReaderViewPager extends ViewPager {
|
|||||||
mOnChapterBoundariesOutListener.onLastPageOutEvent();
|
mOnChapterBoundariesOutListener.onLastPageOutEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (mOnChapterSingleTapListener != null) {
|
||||||
|
mOnChapterSingleTapListener.onSingleTap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user