Fix alignment changes resetting reader article position #190
@ -209,28 +209,24 @@ class ReaderActivity :
|
||||
}
|
||||
}
|
||||
|
||||
R.id.align_left -> {
|
||||
switchAlignmentSetting(AppSettingsService.ALIGN_LEFT)
|
||||
refreshFragment()
|
||||
}
|
||||
R.id.align_left -> switchAlignmentSetting(AppSettingsService.ALIGN_LEFT)
|
||||
|
||||
R.id.align_justify -> {
|
||||
switchAlignmentSetting(AppSettingsService.JUSTIFY)
|
||||
refreshFragment()
|
||||
}
|
||||
R.id.align_justify -> switchAlignmentSetting(AppSettingsService.JUSTIFY)
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun switchAlignmentSetting(allignment: Int) {
|
||||
appSettingsService.changeAllignment(allignment)
|
||||
private fun switchAlignmentSetting(alignment: Int) {
|
||||
appSettingsService.changeAllignment(alignment)
|
||||
alignmentMenu()
|
||||
}
|
||||
|
||||
private fun refreshFragment() {
|
||||
finish()
|
||||
overridePendingTransition(0, 0)
|
||||
startActivity(intent)
|
||||
overridePendingTransition(0, 0)
|
||||
val fragmentManager = supportFragmentManager
|
||||
val fragments = fragmentManager.fragments
|
||||
|
||||
for (fragment in fragments) {
|
||||
if (fragment is ArticleFragment) {
|
||||
fragment.refreshAlignment()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -263,13 +263,15 @@ class ArticleFragment :
|
||||
)
|
||||
}
|
||||
|
||||
private fun refreshAlignment() {
|
||||
fun refreshAlignment() {
|
||||
textAlignment =
|
||||
when (appSettingsService.getActiveAllignment()) {
|
||||
1 -> "justify"
|
||||
2 -> "left"
|
||||
else -> "justify"
|
||||
}
|
||||
|
||||
htmlToWebview()
|
||||
}
|
||||
|
||||
@Suppress("detekt:SwallowedException")
|
||||
|
Loading…
x
Reference in New Issue
Block a user