Fix snackbar not showing (#2140)

This commit is contained in:
Howard Wu 2022-09-25 19:06:36 +08:00 committed by GitHub
parent 135a7d69f8
commit 5262c52c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -134,8 +134,9 @@ public class BaseFragment extends Fragment {
var snackbar = Snackbar.make(container, str, lengthShort ? Snackbar.LENGTH_SHORT : Snackbar.LENGTH_LONG);
if (container.findViewById(R.id.nav) instanceof BottomNavigationView)
snackbar.setAnchorView(R.id.nav);
if (container.findViewById(R.id.fab) instanceof FloatingActionButton)
snackbar.setAnchorView(R.id.fab);
var fab = container.findViewById(R.id.fab);
if (fab instanceof FloatingActionButton && ((FloatingActionButton) fab).isOrWillBeShown())
snackbar.setAnchorView(fab);
if (actionStr != null && action != null) snackbar.setAction(actionStr, action);
snackbar.show();
return;