This repository was archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Migrate to ViewPager2 #349
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
af74530
Start of migration to ViewPager2
stevenzeck 1fd819e
Fix search and reading settings
stevenzeck f6ed204
Fix RTL paging. Remove commented out code. Some condensing of all of …
stevenzeck ca3fb1d
Make suggested changes in webview listener, fix scroll mode, fix snap…
stevenzeck e87bf79
Merge branch 'alpha' into viewpager2
mickael-menu 55ef5d6
Merge branch 'alpha' into viewpager2
mickael-menu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -575,7 +575,8 @@ class EpubActivity : R2EpubActivity(), CoroutineScope, NavigatorDelegate/*, Visu | |
val searchStorage = getSharedPreferences("org.readium.r2.search", Context.MODE_PRIVATE) | ||
Handler().postDelayed({ | ||
if (publication.metadata.presentation.layout == EpubLayout.REFLOWABLE) { | ||
val currentFragment = (resourcePager.adapter as R2PagerAdapter).getCurrentFragment() as R2EpubPageFragment | ||
// val currentFragment = (resourcePager.adapter as R2PagerAdapter).getCurrentFragment() as R2EpubPageFragment | ||
val currentFragment = (resourcePager.adapter as R2PagerAdapter).fm.findFragmentByTag("f${resourcePager.currentItem}") as R2EpubPageFragment | ||
val resource = publication.readingOrder[resourcePager.currentItem] | ||
val resourceHref = resource.href | ||
val resourceType = resource.type ?: "" | ||
|
@@ -600,7 +601,8 @@ class EpubActivity : R2EpubActivity(), CoroutineScope, NavigatorDelegate/*, Visu | |
mode?.menu?.run { | ||
menuInflater.inflate(R.menu.menu_action_mode, this) | ||
findItem(R.id.highlight).setOnMenuItemClickListener { | ||
val currentFragment = ((resourcePager.adapter as R2PagerAdapter).mFragments.get((resourcePager.adapter as R2PagerAdapter).getItemId(resourcePager.currentItem))) as? R2EpubPageFragment | ||
// val currentFragment = ((resourcePager.adapter as R2PagerAdapter).mFragments.get((resourcePager.adapter as R2PagerAdapter).getItemId(resourcePager.currentItem))) as? R2EpubPageFragment | ||
val currentFragment = (resourcePager.adapter as R2PagerAdapter).fm.findFragmentByTag("f${resourcePager.currentItem}") as? R2EpubPageFragment | ||
Comment on lines
+604
to
+605
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stevenzeck Same thing, maybe there's a way to have |
||
|
||
currentFragment?.webView?.getCurrentSelectionRect { | ||
val rect = JSONObject(it).run { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
android:layout_height="match_parent" | ||
tools:context="org.readium.r2.navigator.epub.R2EpubActivity"> | ||
|
||
<org.readium.r2.navigator.pager.R2ViewPager | ||
<androidx.viewpager2.widget.ViewPager2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stevenzeck We should look for a way to have |
||
android:id="@+id/resourcePager" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevenzeck To minimize breaking changes, we can add back a
getCurrentFragment()
API inR2PagerAdapter
which will dofm.findFragmentByTag("f${resourcePager.currentItem}")