mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
animate FAB to move up and down when a snackbar appears
This commit is contained in:
parent
c8f5dc5cf3
commit
d64b8f47d1
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -619,23 +620,21 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutParams mFabOrigin = null;
|
|
||||||
@Override
|
@Override
|
||||||
public void fabMoveUp(int height) {
|
public void fabMoveUp(int height) {
|
||||||
if (mFabOrigin == null) {
|
ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, "translationY", 0, -height);
|
||||||
mFabOrigin = mFab.getLayoutParams();
|
// we're a little behind, so skip 1/10 of the time
|
||||||
}
|
anim.setDuration(270);
|
||||||
|
anim.start();
|
||||||
// TODO reposition properly!
|
|
||||||
MarginLayoutParams marginParams = new MarginLayoutParams(mFabOrigin);
|
|
||||||
marginParams.setMargins(0, 0, 16, 16+height);
|
|
||||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
|
|
||||||
mFab.setLayoutParams(layoutParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabRestorePosition() {
|
public void fabRestorePosition() {
|
||||||
mFab.setLayoutParams(mFabOrigin);
|
ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, "translationY", 0);
|
||||||
|
// we're a little ahead, so wait a few ms
|
||||||
|
anim.setStartDelay(70);
|
||||||
|
anim.setDuration(300);
|
||||||
|
anim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user