diff options
author | Harsh Shandilya <harsh@prjkt.io> | 2018-07-17 20:31:41 +0530 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-18 02:15:06 +0200 |
commit | df0d2eb452de15a9f4b7078e379eabf34cba405b (patch) | |
tree | 93e5076cfa85b8d2c120f96ec37a709ca27108b2 /app/src/main/java/com/wireguard | |
parent | c6dd48330e98cff3ae077f85c0422d4faf5b7215 (diff) |
fab: slide fab up when a snackbar shows
Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
Diffstat (limited to 'app/src/main/java/com/wireguard')
-rw-r--r-- | app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java new file mode 100644 index 00000000..84868a4c --- /dev/null +++ b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2018 Harsh Shandilya <msfjarvis@gmail.com> + * Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.android.widget.fab; + +import android.content.Context; +import android.support.design.widget.CoordinatorLayout; +import android.support.design.widget.Snackbar; +import android.util.AttributeSet; +import android.view.View; + +public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior<FloatingActionsMenu> { + + public FloatingActionButtonBehavior(final Context context, final AttributeSet attrs) { } + + @Override + public boolean layoutDependsOn(final CoordinatorLayout parent, final FloatingActionsMenu child, + final View dependency) { + return dependency instanceof Snackbar.SnackbarLayout; + } + + @Override + public boolean onDependentViewChanged(final CoordinatorLayout parent, final FloatingActionsMenu child, + final View dependency) { + final float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); + child.setTranslationY(translationY); + return true; + } +} |