improve pin clicking animation jumping.

refactor-toolbar
Floens 8 years ago
parent ae916f1f4e
commit 481e6d9e2a
  1. 5
      Clover/app/src/main/java/org/floens/chan/ui/controller/DrawerController.java
  2. 15
      Clover/app/src/main/java/org/floens/chan/ui/view/LoadView.java

@ -138,7 +138,10 @@ public class DrawerController extends Controller implements DrawerAdapter.Callba
@Override @Override
public void onPinClicked(Pin pin) { public void onPinClicked(Pin pin) {
drawerLayout.closeDrawer(Gravity.LEFT); // Post it to avoid animation jumping because the first frame is heavy.
// TODO: probably twice because of some force redraw, fix that.
drawerLayout.post(() -> drawerLayout.post(() -> drawerLayout.closeDrawer(drawer)));
ThreadController threadController = getTopThreadController(); ThreadController threadController = getTopThreadController();
threadController.openPin(pin); threadController.openPin(pin);
} }

@ -146,7 +146,20 @@ public class LoadView extends FrameLayout {
animatorSet.setDuration(fadeDuration); animatorSet.setDuration(fadeDuration);
animatorSet.playTogether(animators); animatorSet.playTogether(animators);
animatorSet.start();
final AnimatorSet currentAnimatorSet = animatorSet;
// Postponing the animation to the next frame delays the animation until the heavy
// view setup is done. If you start the animation immediately, it will jump because
// the first frame is nowhere near 16ms. We rather have a bit of a delay instead of
// a broken jumping animation.
post(() -> {
// The AnimatorSet is replaced with a new one, if it was changed between the
// previous frame and now.
if (animatorSet == currentAnimatorSet) {
animatorSet.start();
}
});
} else { } else {
// Fast forward possible pending animations (end, so also remove them). // Fast forward possible pending animations (end, so also remove them).
animatorSet.end(); animatorSet.end();

Loading…
Cancel
Save