|
@@ -77,14 +77,13 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
if (savedState != null && readerMenu.showing)
|
|
if (savedState != null && readerMenu.showing)
|
|
readerMenu.show(false);
|
|
readerMenu.show(false);
|
|
|
|
|
|
- enableHardwareAcceleration();
|
|
|
|
-
|
|
|
|
initializeSettings();
|
|
initializeSettings();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
readerMenu.destroy();
|
|
readerMenu.destroy();
|
|
|
|
+ viewer.destroy();
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -97,7 +96,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
@Override
|
|
@Override
|
|
protected void onPause() {
|
|
protected void onPause() {
|
|
getPresenter().setCurrentPage(viewer.getCurrentPosition());
|
|
getPresenter().setCurrentPage(viewer.getCurrentPosition());
|
|
- viewer.destroySubscriptions();
|
|
|
|
super.onPause();
|
|
super.onPause();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,13 +105,9 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
super.onSaveInstanceState(outState);
|
|
super.onSaveInstanceState(outState);
|
|
}
|
|
}
|
|
|
|
|
|
- private void createUiHideFlags(boolean statusBarHidden) {
|
|
|
|
- uiFlags = 0;
|
|
|
|
- uiFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
|
|
- if (statusBarHidden)
|
|
|
|
- uiFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
|
|
|
- uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
|
|
|
|
+ public void onChapterError() {
|
|
|
|
+ finish();
|
|
|
|
+ ToastUtil.showShort(this, R.string.page_list_error);
|
|
}
|
|
}
|
|
|
|
|
|
public void onChapterReady(List<Page> pages, Manga manga, Chapter chapter) {
|
|
public void onChapterReady(List<Page> pages, Manga manga, Chapter chapter) {
|
|
@@ -123,9 +117,19 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
readerMenu.onChapterReady(pages.size(), manga, chapter);
|
|
readerMenu.onChapterReady(pages.size(), manga, chapter);
|
|
}
|
|
}
|
|
|
|
|
|
- public void onChapterError() {
|
|
|
|
- finish();
|
|
|
|
- ToastUtil.showShort(this, R.string.page_list_error);
|
|
|
|
|
|
+ private BaseReader createViewer(Manga manga) {
|
|
|
|
+ int mangaViewer = manga.viewer == 0 ? preferences.getDefaultViewer() : manga.viewer;
|
|
|
|
+
|
|
|
|
+ switch (mangaViewer) {
|
|
|
|
+ case LEFT_TO_RIGHT: default:
|
|
|
|
+ return new LeftToRightReader(this);
|
|
|
|
+ case RIGHT_TO_LEFT:
|
|
|
|
+ return new RightToLeftReader(this);
|
|
|
|
+ case VERTICAL:
|
|
|
|
+ return new VerticalReader(this);
|
|
|
|
+ case WEBTOON:
|
|
|
|
+ return new WebtoonReader(this);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void onPageChanged(int currentPageIndex, int totalPages) {
|
|
public void onPageChanged(int currentPageIndex, int totalPages) {
|
|
@@ -138,16 +142,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
viewer.setSelectedPage(pageIndex);
|
|
viewer.setSelectedPage(pageIndex);
|
|
}
|
|
}
|
|
|
|
|
|
- public void setSystemUiVisibility() {
|
|
|
|
- getWindow().getDecorView().setSystemUiVisibility(uiFlags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void enableHardwareAcceleration() {
|
|
|
|
- getWindow().setFlags(
|
|
|
|
- WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
|
|
|
- WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public boolean onImageSingleTap(MotionEvent motionEvent) {
|
|
public boolean onImageSingleTap(MotionEvent motionEvent) {
|
|
return viewer.onImageTouch(motionEvent);
|
|
return viewer.onImageTouch(motionEvent);
|
|
}
|
|
}
|
|
@@ -156,29 +150,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
readerMenu.toggle();
|
|
readerMenu.toggle();
|
|
}
|
|
}
|
|
|
|
|
|
- public ViewGroup getContainer() {
|
|
|
|
- return container;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public PreferencesHelper getPreferences() {
|
|
|
|
- return preferences;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private BaseReader createViewer(Manga manga) {
|
|
|
|
- int mangaViewer = manga.viewer == 0 ? preferences.getDefaultViewer() : manga.viewer;
|
|
|
|
-
|
|
|
|
- switch (mangaViewer) {
|
|
|
|
- case LEFT_TO_RIGHT: default:
|
|
|
|
- return new LeftToRightReader(this);
|
|
|
|
- case RIGHT_TO_LEFT:
|
|
|
|
- return new RightToLeftReader(this);
|
|
|
|
- case VERTICAL:
|
|
|
|
- return new VerticalReader(this);
|
|
|
|
- case WEBTOON:
|
|
|
|
- return new WebtoonReader(this);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void initializeSettings() {
|
|
private void initializeSettings() {
|
|
subscriptions.add(preferences.showPageNumber()
|
|
subscriptions.add(preferences.showPageNumber()
|
|
.asObservable()
|
|
.asObservable()
|
|
@@ -226,11 +197,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
pageNumber.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
|
pageNumber.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
- private void setStatusBarVisibility(boolean hidden) {
|
|
|
|
- createUiHideFlags(hidden);
|
|
|
|
- setSystemUiVisibility();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void setKeepScreenOn(boolean enabled) {
|
|
private void setKeepScreenOn(boolean enabled) {
|
|
if (enabled) {
|
|
if (enabled) {
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
@@ -238,10 +204,36 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private void setStatusBarVisibility(boolean hidden) {
|
|
|
|
+ createUiHideFlags(hidden);
|
|
|
|
+ setSystemUiVisibility();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createUiHideFlags(boolean statusBarHidden) {
|
|
|
|
+ uiFlags = 0;
|
|
|
|
+ uiFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
|
|
+ if (statusBarHidden)
|
|
|
|
+ uiFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
|
|
|
+ uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSystemUiVisibility() {
|
|
|
|
+ getWindow().getDecorView().setSystemUiVisibility(uiFlags);
|
|
|
|
+ }
|
|
|
|
+
|
|
protected void setMangaDefaultViewer(int viewer) {
|
|
protected void setMangaDefaultViewer(int viewer) {
|
|
getPresenter().updateMangaViewer(viewer);
|
|
getPresenter().updateMangaViewer(viewer);
|
|
recreate();
|
|
recreate();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public ViewGroup getContainer() {
|
|
|
|
+ return container;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PreferencesHelper getPreferences() {
|
|
|
|
+ return preferences;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|