Skip to content

Commit

Permalink
fix(android): fix an issue resulting in initial android settings not …
Browse files Browse the repository at this point in the history
…being applied correctly

#17
  • Loading branch information
jspizziri committed Dec 6, 2022
1 parent 65269c0 commit 9f48874
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions android/src/main/java/com/reactnativereadium/ReadiumView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ReadiumView(
var file: File? = null
var fragment: BaseReaderFragment? = null
var isViewInitialized: Boolean = false
var lateInitSettings: Map<String, Any>? = null

fun updateLocation(location: LinkOrLocator) : Boolean {
if (fragment == null) {
Expand All @@ -30,15 +31,25 @@ class ReadiumView(
}
}

fun updateSettingsFromMap(map: Map<String, Any>) {
if (fragment != null && fragment is EpubReaderFragment) {
fun updateSettingsFromMap(map: Map<String, Any>?) {
if (map == null) {
return
} else if (fragment == null) {
lateInitSettings = map
return
}

if (fragment is EpubReaderFragment) {
(fragment as EpubReaderFragment).updateSettingsFromMap(map)
}

lateInitSettings = null
}

fun addFragment(frag: BaseReaderFragment) {
fragment = frag
setupLayout()
updateSettingsFromMap(lateInitSettings)
val activity: FragmentActivity? = reactContext.currentActivity as FragmentActivity?
activity!!.supportFragmentManager
.beginTransaction()
Expand Down

0 comments on commit 9f48874

Please sign in to comment.