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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/DesktopView.java

Issue 1297073004: Fix various errorprone warnings and errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 16 matching lines...) Expand all
27 import org.chromium.chromoting.jni.JniInterface; 27 import org.chromium.chromoting.jni.JniInterface;
28 28
29 /** 29 /**
30 * The user interface for viewing and interacting with a specific remote host. 30 * The user interface for viewing and interacting with a specific remote host.
31 * It provides a canvas onto which the video feed is rendered, handles 31 * It provides a canvas onto which the video feed is rendered, handles
32 * multitouch pan and zoom gestures, and collects and forwards input events. 32 * multitouch pan and zoom gestures, and collects and forwards input events.
33 */ 33 */
34 /** GUI element that holds the drawing canvas. */ 34 /** GUI element that holds the drawing canvas. */
35 public class DesktopView extends SurfaceView implements DesktopViewInterface, 35 public class DesktopView extends SurfaceView implements DesktopViewInterface,
36 SurfaceHolder.Callback { 36 SurfaceHolder.Callback {
37 private RenderData mRenderData; 37 private final RenderData mRenderData;
38 private TouchInputHandler mInputHandler; 38 private TouchInputHandler mInputHandler;
39 39
40 /** The parent Desktop activity. */ 40 /** The parent Desktop activity. */
41 private Desktop mDesktop; 41 private Desktop mDesktop;
42 42
43 // Flag to prevent multiple repaint requests from being backed up. Requests for repainting will 43 // Flag to prevent multiple repaint requests from being backed up. Requests for repainting will
44 // be dropped if this is already set to true. This is used by the main threa d and the painting 44 // be dropped if this is already set to true. This is used by the main threa d and the painting
45 // thread, so the access should be synchronized on |mRenderData|. 45 // thread, so the access should be synchronized on |mRenderData|.
46 private boolean mRepaintPending; 46 private boolean mRepaintPending;
47 47
48 // Flag used to ensure that the SurfaceView is only painted between calls to surfaceCreated() 48 // Flag used to ensure that the SurfaceView is only painted between calls to surfaceCreated()
49 // and surfaceDestroyed(). Accessed on main thread and display thread, so th is should be 49 // and surfaceDestroyed(). Accessed on main thread and display thread, so th is should be
50 // synchronized on |mRenderData|. 50 // synchronized on |mRenderData|.
51 private boolean mSurfaceCreated = false; 51 private boolean mSurfaceCreated = false;
52 52
53 /** Helper class for displaying the long-press feedback animation. This clas s is thread-safe. */ 53 /** Helper class for displaying the long-press feedback animation. This clas s is thread-safe. */
54 private static class FeedbackAnimator { 54 private static class FeedbackAnimator {
55 /** Total duration of the animation, in milliseconds. */ 55 /** Total duration of the animation, in milliseconds. */
56 private static final float TOTAL_DURATION_MS = 220; 56 private static final float TOTAL_DURATION_MS = 220;
57 57
58 /** Start time of the animation, from {@link SystemClock#uptimeMillis()} . */ 58 /** Start time of the animation, from {@link SystemClock#uptimeMillis()} . */
59 private long mStartTime = 0; 59 private long mStartTime = 0;
60 60
61 private boolean mRunning = false; 61 private boolean mRunning = false;
62 62
63 /** Lock to allow multithreaded access to {@link #mStartTime} and {@link #mRunning}. */ 63 /** Lock to allow multithreaded access to {@link #mStartTime} and {@link #mRunning}. */
64 private Object mLock = new Object(); 64 private final Object mLock = new Object();
65 65
66 private Paint mPaint = new Paint(); 66 private Paint mPaint = new Paint();
67 67
68 public boolean isAnimationRunning() { 68 public boolean isAnimationRunning() {
69 synchronized (mLock) { 69 synchronized (mLock) {
70 return mRunning; 70 return mRunning;
71 } 71 }
72 } 72 }
73 73
74 /** 74 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 new float[] {0.0f, 0.8f, 0.9f, 1.0f}, Shader.TileMode.CLAMP) ); 108 new float[] {0.0f, 0.8f, 0.9f, 1.0f}, Shader.TileMode.CLAMP) );
109 canvas.drawCircle(x, y, radius, mPaint); 109 canvas.drawCircle(x, y, radius, mPaint);
110 } 110 }
111 } 111 }
112 112
113 private FeedbackAnimator mFeedbackAnimator = new FeedbackAnimator(); 113 private FeedbackAnimator mFeedbackAnimator = new FeedbackAnimator();
114 114
115 // Variables to control animation by the TouchInputHandler. 115 // Variables to control animation by the TouchInputHandler.
116 116
117 /** Protects mInputAnimationRunning. */ 117 /** Protects mInputAnimationRunning. */
118 private Object mAnimationLock = new Object(); 118 private final Object mAnimationLock = new Object();
119 119
120 /** Whether the TouchInputHandler has requested animation to be performed. * / 120 /** Whether the TouchInputHandler has requested animation to be performed. * /
121 private boolean mInputAnimationRunning = false; 121 private boolean mInputAnimationRunning = false;
122 122
123 public DesktopView(Context context, AttributeSet attributes) { 123 public DesktopView(Context context, AttributeSet attributes) {
124 super(context, attributes); 124 super(context, attributes);
125 125
126 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. 126 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
127 setFocusableInTouchMode(true); 127 setFocusableInTouchMode(true);
128 128
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 @Override 378 @Override
379 public void setAnimationEnabled(boolean enabled) { 379 public void setAnimationEnabled(boolean enabled) {
380 synchronized (mAnimationLock) { 380 synchronized (mAnimationLock) {
381 if (enabled && !mInputAnimationRunning) { 381 if (enabled && !mInputAnimationRunning) {
382 requestRepaint(); 382 requestRepaint();
383 } 383 }
384 mInputAnimationRunning = enabled; 384 mInputAnimationRunning = enabled;
385 } 385 }
386 } 386 }
387 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698