am 48c51e59: am 7ae9fe16: am 624e90dc: am b1a51676: Fix offset calculation math

* commit '48c51e594853c0f5a840dc6b75690b2af9d48dec':
  Fix offset calculation math

GitOrigin-RevId=ba8b85a4ef455d64bb2cf640c47bc47eac657347

PiperOrigin-RevId: 140548657
This commit is contained in:
Chris Banes 2016-11-30 01:18:19 +00:00 committed by Travis Collins
parent e3ab398a87
commit ba415acdc2

View File

@ -16,9 +16,9 @@
package android.support.design.widget;
import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.view.ViewParent;
/**
* Utility helper for moving a {@link android.view.View} around using
@ -51,15 +51,15 @@ class ViewOffsetHelper {
}
private void updateOffsets() {
if (Build.VERSION.SDK_INT == 22) {
// FIXME When running on L MR1, we have a problem with view's which are offset off
// screen then back on. Using translationX/Y fixes it for now.
ViewCompat.setTranslationY(mView, mOffsetTop);
ViewCompat.setTranslationX(mView, mOffsetLeft);
} else {
// Else we can use the offset position methods
ViewCompat.offsetTopAndBottom(mView, mOffsetTop - mView.getTop() - mLayoutTop);
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - mView.getLeft() - mLayoutLeft);
if (mOffsetLeft != 0 || mOffsetTop != 0) {
ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
// Manually invalidate the parent to make sure we get drawn
ViewParent parent = mView.getParent();
if (parent instanceof View) {
((View) parent).invalidate();
}
}
}