@@ -139,64 +139,72 @@ class EpubNavigatorFragment private constructor(
139139 resourcePager = binding.resourcePager
140140 resourcePager.type = Publication .TYPE .EPUB
141141
142- if (publication.metadata.presentation.layout == EpubLayout .REFLOWABLE ) {
143- resourcesSingle = publication.readingOrder.mapIndexed { index, link ->
144- PageResource .EpubReflowable (
145- link = link,
146- url = link.withBaseUrl(baseUrl).href,
147- positionCount = positionsByReadingOrder.getOrNull(index)?.size ? : 0
148- )
149- }
142+ when (publication.metadata.presentation.layout) {
143+ EpubLayout .REFLOWABLE , null -> {
144+ resourcesSingle = publication.readingOrder.mapIndexed { index, link ->
145+ PageResource .EpubReflowable (
146+ link = link,
147+ url = link.withBaseUrl(baseUrl).href,
148+ positionCount = positionsByReadingOrder.getOrNull(index)?.size ? : 0
149+ )
150+ }
150151
151- adapter = R2PagerAdapter (childFragmentManager, resourcesSingle)
152- resourcePager.type = Publication .TYPE .EPUB
152+ adapter = R2PagerAdapter (childFragmentManager, resourcesSingle)
153+ resourcePager.type = Publication .TYPE .EPUB
154+ }
153155
154- } else {
155- val resourcesSingle = mutableListOf<PageResource >()
156- val resourcesDouble = mutableListOf<PageResource >()
156+ EpubLayout . FIXED -> {
157+ val resourcesSingle = mutableListOf<PageResource >()
158+ val resourcesDouble = mutableListOf<PageResource >()
157159
158- // TODO needs work, currently showing two resources for fxl, needs to understand which two resources, left & right, or only right etc.
159- var doublePageLeft = " "
160- var doublePageRight = " "
160+ // TODO needs work, currently showing two resources for fxl, needs to understand which two resources, left & right, or only right etc.
161+ var doublePageLeft = " "
162+ var doublePageRight = " "
161163
162- for ((index, link) in publication.readingOrder.withIndex()) {
163- val url = link.withBaseUrl(baseUrl).href
164- resourcesSingle.add(PageResource .EpubFxl (url))
164+ for ((index, link) in publication.readingOrder.withIndex()) {
165+ val url = link.withBaseUrl(baseUrl).href
166+ resourcesSingle.add(PageResource .EpubFxl (url))
165167
166- // add first page to the right,
167- if (index == 0 ) {
168- resourcesDouble.add(PageResource .EpubFxl (" " , url))
169- } else {
170- // add double pages, left & right
171- if (doublePageLeft == " " ) {
172- doublePageLeft = url
168+ // add first page to the right,
169+ if (index == 0 ) {
170+ resourcesDouble.add(PageResource .EpubFxl (" " , url))
173171 } else {
174- doublePageRight = url
175- resourcesDouble.add(PageResource .EpubFxl (doublePageLeft, doublePageRight))
176- doublePageLeft = " "
172+ // add double pages, left & right
173+ if (doublePageLeft == " " ) {
174+ doublePageLeft = url
175+ } else {
176+ doublePageRight = url
177+ resourcesDouble.add(
178+ PageResource .EpubFxl (
179+ doublePageLeft,
180+ doublePageRight
181+ )
182+ )
183+ doublePageLeft = " "
184+ }
177185 }
178186 }
179- }
180- // add last page if there is only a left page remaining
181- if (doublePageLeft != " " ) {
182- resourcesDouble.add(PageResource .EpubFxl (doublePageLeft, " " ))
183- }
187+ // add last page if there is only a left page remaining
188+ if (doublePageLeft != " " ) {
189+ resourcesDouble.add(PageResource .EpubFxl (doublePageLeft, " " ))
190+ }
184191
185- this .resourcesSingle = resourcesSingle
186- this .resourcesDouble = resourcesDouble
192+ this .resourcesSingle = resourcesSingle
193+ this .resourcesDouble = resourcesDouble
187194
188- resourcePager.type = Publication .TYPE .FXL
189- adapter = when (preferences.getInt(COLUMN_COUNT_REF , 0 )) {
190- 1 -> {
191- R2PagerAdapter (childFragmentManager, resourcesSingle)
192- }
193- 2 -> {
194- R2PagerAdapter (childFragmentManager, resourcesDouble)
195- }
196- else -> {
197- // TODO based on device
198- // TODO decide if 1 page or 2 page
199- R2PagerAdapter (childFragmentManager, resourcesSingle)
195+ resourcePager.type = Publication .TYPE .FXL
196+ adapter = when (preferences.getInt(COLUMN_COUNT_REF , 0 )) {
197+ 1 -> {
198+ R2PagerAdapter (childFragmentManager, resourcesSingle)
199+ }
200+ 2 -> {
201+ R2PagerAdapter (childFragmentManager, resourcesDouble)
202+ }
203+ else -> {
204+ // TODO based on device
205+ // TODO decide if 1 page or 2 page
206+ R2PagerAdapter (childFragmentManager, resourcesSingle)
207+ }
200208 }
201209 }
202210 }
0 commit comments