From 9dd9c995a8a4e3de8bd2d7ddb996ea3f9471b46a Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 21 Nov 2015 03:56:07 +0100 Subject: [PATCH] Some reordering and renaming --- app/src/main/AndroidManifest.xml | 3 +- .../mangafeed/ui/reader/ReaderActivity.java | 106 ++++++++---------- .../ui/reader/viewer/base/BaseReader.java | 2 +- .../viewer/horizontal/HorizontalReader.java | 2 +- .../reader/viewer/webtoon/WebtoonReader.java | 2 +- 5 files changed, 54 insertions(+), 61 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a2b5742e7..0308bafc0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -28,7 +28,8 @@ + android:parentActivityName=".ui.manga.MangaActivity" + android:hardwareAccelerated="true"> diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java index cea52c4e1..a54154c76 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java @@ -77,14 +77,13 @@ public class ReaderActivity extends BaseRxActivity { if (savedState != null && readerMenu.showing) readerMenu.show(false); - enableHardwareAcceleration(); - initializeSettings(); } @Override protected void onDestroy() { readerMenu.destroy(); + viewer.destroy(); super.onDestroy(); } @@ -97,7 +96,6 @@ public class ReaderActivity extends BaseRxActivity { @Override protected void onPause() { getPresenter().setCurrentPage(viewer.getCurrentPosition()); - viewer.destroySubscriptions(); super.onPause(); } @@ -107,13 +105,9 @@ public class ReaderActivity extends BaseRxActivity { 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 pages, Manga manga, Chapter chapter) { @@ -123,47 +117,6 @@ public class ReaderActivity extends BaseRxActivity { readerMenu.onChapterReady(pages.size(), manga, chapter); } - public void onChapterError() { - finish(); - ToastUtil.showShort(this, R.string.page_list_error); - } - - public void onPageChanged(int currentPageIndex, int totalPages) { - String page = (currentPageIndex + 1) + "/" + totalPages; - pageNumber.setText(page); - readerMenu.onPageChanged(currentPageIndex); - } - - public void setSelectedPage(int 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) { - return viewer.onImageTouch(motionEvent); - } - - public void onCenterSingleTap() { - 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; @@ -179,6 +132,24 @@ public class ReaderActivity extends BaseRxActivity { } } + public void onPageChanged(int currentPageIndex, int totalPages) { + String page = (currentPageIndex + 1) + "/" + totalPages; + pageNumber.setText(page); + readerMenu.onPageChanged(currentPageIndex); + } + + public void setSelectedPage(int pageIndex) { + viewer.setSelectedPage(pageIndex); + } + + public boolean onImageSingleTap(MotionEvent motionEvent) { + return viewer.onImageTouch(motionEvent); + } + + public void onCenterSingleTap() { + readerMenu.toggle(); + } + private void initializeSettings() { subscriptions.add(preferences.showPageNumber() .asObservable() @@ -226,11 +197,6 @@ public class ReaderActivity extends BaseRxActivity { pageNumber.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); } - private void setStatusBarVisibility(boolean hidden) { - createUiHideFlags(hidden); - setSystemUiVisibility(); - } - private void setKeepScreenOn(boolean enabled) { if (enabled) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -238,10 +204,36 @@ public class ReaderActivity extends BaseRxActivity { 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) { getPresenter().updateMangaViewer(viewer); recreate(); } + public ViewGroup getContainer() { + return container; + } + + public PreferencesHelper getPreferences() { + return preferences; + } + } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java index 070ff3cab..293c67236 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java @@ -43,7 +43,7 @@ public abstract class BaseReader { activity.getPresenter().loadPreviousChapter(); } - public void destroySubscriptions() {} + public void destroy() {} public abstract int getTotalPages(); public abstract void setSelectedPage(int pageNumber); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java index 8670c8b26..75cd304b6 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java @@ -90,7 +90,7 @@ public abstract class HorizontalReader extends BaseReader { } @Override - public void destroySubscriptions() { + public void destroy() { transitionsSubscription.unsubscribe(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java index a5d63bfc5..2cc591a8f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java @@ -100,7 +100,7 @@ public class WebtoonReader extends BaseReader { } @Override - public void destroySubscriptions() { + public void destroy() { if (subscription != null && !subscription.isUnsubscribed()) subscription.unsubscribe(); }