Skip to content

Commit 508a1a9

Browse files
tweak fab hiding
should no longer show slight edges would be nice to get rid of translucency on searchview tho Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent afb62c0 commit 508a1a9

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,21 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
240240
moduleList.addOnScrollListener(object : RecyclerView.OnScrollListener() {
241241
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
242242
if (newState != RecyclerView.SCROLL_STATE_IDLE) searchView.clearFocus()
243-
// hide search view and reboot fab when scrolling
243+
// hide search view and reboot fab when scrolling - we have to account for padding, corners, and shadows
244244
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
245-
searchCard.animate().translationY(-searchCard.height.toFloat())
246-
.setInterpolator(AccelerateInterpolator(2f)).start()
247-
rebootFab.animate().translationY(rebootFab.height.toFloat())
248-
.setInterpolator(AccelerateInterpolator(2f)).start()
245+
searchCard.animate().translationY(-searchCard.height.toFloat() - 2 * 8 - 2 * 2)
246+
.setInterpolator(DecelerateInterpolator(2f)).start()
247+
rebootFab.animate().translationY(rebootFab.height.toFloat() + 2 * 8 + 2 * 2)
248+
.setInterpolator(DecelerateInterpolator(2f)).start()
249249
}
250250
}
251251

252252
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
253253
super.onScrolled(recyclerView, dx, dy)
254254
// if the user scrolled up, show the search bar
255255
if (dy < 0) {
256-
searchCard.animate().translationY(0f)
257-
.setInterpolator(DecelerateInterpolator(2f)).start()
256+
searchCard.animate().translationY(0f).setInterpolator(DecelerateInterpolator(2f))
257+
.start()
258258
rebootFab.animate().translationY(0f).setInterpolator(DecelerateInterpolator(2f))
259259
.start()
260260
}
@@ -266,10 +266,10 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
266266
if (newState != RecyclerView.SCROLL_STATE_IDLE) searchView.clearFocus()
267267
// hide search view when scrolling
268268
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
269-
searchCard.animate().translationY(-searchCard.height.toFloat())
270-
.setInterpolator(AccelerateInterpolator(2f)).start()
271-
rebootFab.animate().translationY(rebootFab.height.toFloat())
272-
.setInterpolator(AccelerateInterpolator(2f)).start()
269+
searchCard.animate().translationY(-searchCard.height.toFloat() - 2 * 8 - 2 * 2)
270+
.setInterpolator(DecelerateInterpolator(2f)).start()
271+
rebootFab.animate().translationY(rebootFab.height.toFloat() + 2 * 8 + 2 * 2)
272+
.setInterpolator(DecelerateInterpolator(2f)).start()
273273
}
274274
}
275275

0 commit comments

Comments
 (0)