animate FAB to move up and down when a snackbar appears

This commit is contained in:
Vincent Breitmoser 2015-02-28 01:17:45 +01:00
parent c8f5dc5cf3
commit d64b8f47d1

View File

@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.app.ProgressDialog;
import android.content.Context;
@ -619,23 +620,21 @@ public class KeyListFragment extends LoaderFragment
}
}
LayoutParams mFabOrigin = null;
@Override
public void fabMoveUp(int height) {
if (mFabOrigin == null) {
mFabOrigin = mFab.getLayoutParams();
}
// 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);
ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, "translationY", 0, -height);
// we're a little behind, so skip 1/10 of the time
anim.setDuration(270);
anim.start();
}
@Override
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();
}
/**