Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java

Issue 2281983004: [Remoting Android] Move setAnimationEnabled to TouchInputHandler (Closed)
Patch Set: Reviewer's Feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/GlDesktopView.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
index 83af5bcf9809fab329ae28472c92da12f608517c..9d89109d3ff82d6f5e8737a8c06af0f0f67a10b8 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
@@ -93,6 +93,8 @@ public class TouchInputHandler {
*/
private boolean mIsDragging = false;
+ private Event.ParameterCallback<Boolean, Void> mProcessAnimationCallback;
+
/**
* This class implements fling animation for cursor
*/
@@ -210,16 +212,37 @@ public class TouchInputHandler {
mCursorAnimationJob = new CursorAnimationJob(context);
mScrollAnimationJob = new ScrollAnimationJob(context);
+ mProcessAnimationCallback = new Event.ParameterCallback<Boolean, Void>() {
+ @Override
+ public Boolean run(Void p) {
+ return processAnimation();
+ }
+ };
+
attachViewEvents(viewer);
}
- public void processAnimation() {
- boolean active = mCursorAnimationJob.processAnimation();
- active |= mScrollAnimationJob.processAnimation();
+ /**
+ * Steps forward the animation.
+ * @return true if the animation is not finished yet.
+ */
+ private boolean processAnimation() {
+ return mCursorAnimationJob.processAnimation() || mScrollAnimationJob.processAnimation();
+ }
- if (!active) {
- mViewer.setAnimationEnabled(false);
- }
+ /**
+ * Start stepping animation when onCanvasRendered is triggered.
+ */
+ private void startAnimation() {
+ mViewer.onCanvasRendered().addSelfRemovable(mProcessAnimationCallback);
+ }
+
+ /**
+ * Abort all animations.
+ */
+ private void abortAnimation() {
+ mCursorAnimationJob.abortAnimation();
+ mScrollAnimationJob.abortAnimation();
}
public void init(Desktop desktop, final InputEventSender injector) {
@@ -324,7 +347,7 @@ public class TouchInputHandler {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
- mViewer.setAnimationEnabled(false);
+ abortAnimation();
mSuppressCursorMovement = false;
mSuppressFling = false;
mSwipeCompleted = false;
@@ -373,8 +396,7 @@ public class TouchInputHandler {
private void setInputStrategy(InputStrategyInterface inputStrategy) {
// Since the rules for flinging differ between input modes, we want to stop running the
// current fling animation when the mode changes to prevent a wonky experience.
- mCursorAnimationJob.abortAnimation();
- mScrollAnimationJob.abortAnimation();
+ abortAnimation();
mInputStrategy = inputStrategy;
}
@@ -519,7 +541,7 @@ public class TouchInputHandler {
if (mScrollFling) {
mScrollAnimationJob.startAnimation(velocityX, velocityY);
- mViewer.setAnimationEnabled(true);
+ startAnimation();
mScrollFling = false;
return true;
}
@@ -532,7 +554,7 @@ public class TouchInputHandler {
// gesture-detector will still generate onFling() notifications based on movement of
// the fingers, which would result in unwanted cursor movement.
mCursorAnimationJob.startAnimation(velocityX, velocityY);
- mViewer.setAnimationEnabled(true);
+ startAnimation();
return true;
}
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/GlDesktopView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698