Add scroll-to-top control for logs
This commit is contained in:
@@ -29,6 +29,12 @@ class ViewLogsFragment : Fragment(R.layout.fragment_view_logs) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding = FragmentViewLogsBinding.bind(view)
|
||||
binding!!.logsRefresh.setOnRefreshListener(::loadLogs)
|
||||
binding!!.logScroll.setOnScrollChangeListener { _, _, scrollY, _, _ ->
|
||||
binding?.scrollToTop?.visibility = if (scrollY > dp(SCROLL_TO_TOP_THRESHOLD_DP)) View.VISIBLE else View.GONE
|
||||
}
|
||||
binding!!.scrollToTop.setOnClickListener {
|
||||
binding?.logScroll?.smoothScrollTo(0, 0)
|
||||
}
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
@@ -236,5 +242,6 @@ class ViewLogsFragment : Fragment(R.layout.fragment_view_logs) {
|
||||
private companion object {
|
||||
const val LEFT_PILL_WEIGHT = 0.42f
|
||||
const val RIGHT_PILL_WEIGHT = 0.58f
|
||||
const val SCROLL_TO_TOP_THRESHOLD_DP = 120
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user