mouse pointer animation fix

This commit is contained in:
Yuriy Liskov
2018-09-17 01:59:05 +03:00
parent c5c88e622d
commit 0a42892d2d
3 changed files with 28 additions and 19 deletions

View File

@@ -594,7 +594,12 @@ public class LeanbackKeyboardContainer {
mSelector.setX(translatedX);
mSelector.setY(translatedY);
} else {
mSelector.animate().x(translatedX).y(translatedY).setInterpolator(sMovementInterpolator).setDuration(MOVEMENT_ANIMATION_DURATION).start();
mSelector.animate()
.x(translatedX)
.y(translatedY)
.setInterpolator(sMovementInterpolator)
.setDuration(MOVEMENT_ANIMATION_DURATION)
.start();
}
}
@@ -1031,6 +1036,10 @@ public class LeanbackKeyboardContainer {
setKbFocus(focus, false, true);
}
public void setFocus(LeanbackKeyboardContainer.KeyFocus focus, final boolean animate) {
setKbFocus(focus, false, animate);
}
public void setSelectorToFocus(Rect rect, boolean overestimateWidth, boolean overestimateHeight, boolean animate) {
if (this.mSelector.getWidth() != 0 && this.mSelector.getHeight() != 0 && rect.width() != 0 && rect.height() != 0) {
final float width = (float) rect.width();

View File

@@ -540,13 +540,10 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
private void moveSelectorToPoint(float x, float y) {
LeanbackKeyboardContainer container = this.mContainer;
LeanbackKeyboardContainer.KeyFocus focus = this.mTempFocus;
container.getBestFocus(new Float(x), new Float(y), focus);
this.mContainer.setFocus(this.mTempFocus);
container = this.mContainer;
Rect rect = this.mTempFocus.rect;
container.alignSelector((float) rect.centerX(), (float) rect.centerY(), false);
LeanbackKeyboardContainer container = mContainer;
LeanbackKeyboardContainer.KeyFocus focus = mTempFocus;
container.getBestFocus(x, y, focus);
mContainer.setFocus(mTempFocus, false);
}
private boolean onDirectionalMove(int dir) {
@@ -634,21 +631,24 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
/**
* Try to handle on hover event
* Control keyboard from the mouse. Movement catching
* @param view active view
* @param event event object
* @return is hover handled
*/
@Override
public boolean onHover(View view, MotionEvent event) {
boolean allowed = isCallAllowed(300);
if (allowed) {
if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
PointF pos = getRelativePosition(mContainer.getView(), event);
moveSelectorToPoint(pos.x, pos.y);
}
}
return false;
return allowed;
//boolean allowed = isCallAllowed(300);
//if (allowed) {
// if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
// PointF pos = getRelativePosition(mContainer.getView(), event);
// moveSelectorToPoint(pos.x, pos.y);
// }
//}
//
//return allowed;
}
/**