mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-13 01:17:21 -04:00
#2418 removed bang operator and formated code
This commit is contained in:
parent
1b2b257afc
commit
5fa1e193dd
@ -256,7 +256,7 @@ class KiwixReaderFragment : CoreReaderFragment() {
|
|||||||
|
|
||||||
override fun createWebView(attrs: AttributeSet): ToolbarScrollingKiwixWebView {
|
override fun createWebView(attrs: AttributeSet): ToolbarScrollingKiwixWebView {
|
||||||
return ToolbarScrollingKiwixWebView(
|
return ToolbarScrollingKiwixWebView(
|
||||||
activity, this, attrs, activityMainRoot as ViewGroup, videoView,
|
requireContext(), this, attrs, activityMainRoot as ViewGroup, videoView,
|
||||||
CoreWebViewClient(this, zimReaderContainer),
|
CoreWebViewClient(this, zimReaderContainer),
|
||||||
toolbarContainer, bottomToolbar, requireActivity().bottom_nav_view,
|
toolbarContainer, bottomToolbar, requireActivity().bottom_nav_view,
|
||||||
sharedPreferenceUtil
|
sharedPreferenceUtil
|
||||||
|
@ -28,27 +28,27 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
|||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
class ToolbarScrollingKiwixWebView(
|
class ToolbarScrollingKiwixWebView(
|
||||||
context: Context?,
|
context: Context,
|
||||||
callback: WebViewCallback?,
|
callback: WebViewCallback,
|
||||||
attrs: AttributeSet?,
|
attrs: AttributeSet,
|
||||||
nonVideoView: ViewGroup?,
|
nonVideoView: ViewGroup,
|
||||||
videoView: ViewGroup?,
|
videoView: ViewGroup,
|
||||||
webViewClient: CoreWebViewClient?,
|
webViewClient: CoreWebViewClient,
|
||||||
private val toolbarView: View,
|
private val toolbarView: View,
|
||||||
private val bottomBarView: View,
|
private val bottomBarView: View,
|
||||||
override var sharedPreferenceUtil: SharedPreferenceUtil
|
override var sharedPreferenceUtil: SharedPreferenceUtil
|
||||||
) : KiwixWebView(context!!, callback!!, attrs!!, nonVideoView!!, videoView!!, webViewClient!!) {
|
) : KiwixWebView(context, callback, attrs, nonVideoView, videoView, webViewClient) {
|
||||||
private val toolbarHeight = getContext().getToolbarHeight()
|
private val toolbarHeight = getContext().getToolbarHeight()
|
||||||
private var parentNavigationBar: View? = null
|
private var parentNavigationBar: View? = null
|
||||||
private var startY = 0f
|
private var startY = 0f
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
context: Context?,
|
context: Context,
|
||||||
callback: WebViewCallback?,
|
callback: WebViewCallback,
|
||||||
attrs: AttributeSet?,
|
attrs: AttributeSet,
|
||||||
nonVideoView: ViewGroup?,
|
nonVideoView: ViewGroup,
|
||||||
videoView: ViewGroup?,
|
videoView: ViewGroup,
|
||||||
webViewClient: CoreWebViewClient?,
|
webViewClient: CoreWebViewClient,
|
||||||
toolbarView: View,
|
toolbarView: View,
|
||||||
bottomBarView: View,
|
bottomBarView: View,
|
||||||
parentNavigationBar: View?,
|
parentNavigationBar: View?,
|
||||||
@ -60,6 +60,10 @@ class ToolbarScrollingKiwixWebView(
|
|||||||
this.parentNavigationBar = parentNavigationBar
|
this.parentNavigationBar = parentNavigationBar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
fixInitalScrollingIssue()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The webview needs to be scrolled with 0 to not be slightly hidden on startup.
|
* The webview needs to be scrolled with 0 to not be slightly hidden on startup.
|
||||||
* See https://github.com/kiwix/kiwix-android/issues/2304 for issue description.
|
* See https://github.com/kiwix/kiwix-android/issues/2304 for issue description.
|
||||||
@ -69,9 +73,8 @@ class ToolbarScrollingKiwixWebView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToolbar(scrollDelta: Int): Boolean {
|
private fun moveToolbar(scrollDelta: Int): Boolean {
|
||||||
val newTranslation: Float
|
|
||||||
val originalTranslation = toolbarView.translationY
|
val originalTranslation = toolbarView.translationY
|
||||||
newTranslation = if (scrollDelta > 0) {
|
val newTranslation = if (scrollDelta > 0) {
|
||||||
// scroll down
|
// scroll down
|
||||||
Math.max(-toolbarHeight.toFloat(), originalTranslation - scrollDelta)
|
Math.max(-toolbarHeight.toFloat(), originalTranslation - scrollDelta)
|
||||||
} else {
|
} else {
|
||||||
@ -81,9 +84,8 @@ class ToolbarScrollingKiwixWebView(
|
|||||||
toolbarView.translationY = newTranslation
|
toolbarView.translationY = newTranslation
|
||||||
bottomBarView.translationY =
|
bottomBarView.translationY =
|
||||||
newTranslation * -1 * (bottomBarView.height / toolbarHeight.toFloat())
|
newTranslation * -1 * (bottomBarView.height / toolbarHeight.toFloat())
|
||||||
if (parentNavigationBar != null) {
|
parentNavigationBar?.let {
|
||||||
parentNavigationBar!!.translationY =
|
it.translationY = newTranslation * -1 * (it.height / toolbarHeight.toFloat())
|
||||||
newTranslation * -1 * (parentNavigationBar!!.height / toolbarHeight.toFloat())
|
|
||||||
}
|
}
|
||||||
this.translationY = newTranslation + toolbarHeight
|
this.translationY = newTranslation + toolbarHeight
|
||||||
return toolbarHeight + newTranslation != 0f && newTranslation != 0f
|
return toolbarHeight + newTranslation != 0f && newTranslation != 0f
|
||||||
@ -129,8 +131,4 @@ class ToolbarScrollingKiwixWebView(
|
|||||||
private fun ensureToolbarHidden() {
|
private fun ensureToolbarHidden() {
|
||||||
moveToolbar(toolbarHeight)
|
moveToolbar(toolbarHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
fixInitalScrollingIssue()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user