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

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

Issue 2348563004: [Remoting Android] Fix split-screen crash (Closed)
Patch Set: s/invalidate/destroy/. Function name is already used. Created 4 years, 3 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
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Desktop.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.text.InputType; 8 import android.text.InputType;
9 import android.util.AttributeSet; 9 import android.util.AttributeSet;
10 import android.view.MotionEvent; 10 import android.view.MotionEvent;
11 import android.view.SurfaceView; 11 import android.view.SurfaceView;
12 import android.view.inputmethod.EditorInfo; 12 import android.view.inputmethod.EditorInfo;
13 import android.view.inputmethod.InputConnection; 13 import android.view.inputmethod.InputConnection;
14 import android.view.inputmethod.InputMethodManager; 14 import android.view.inputmethod.InputMethodManager;
15 15
16 import org.chromium.chromoting.jni.Client; 16 import org.chromium.chromoting.jni.Client;
17 17
18 /** 18 /**
19 * The class for viewing and interacting with a specific remote host. 19 * The class for viewing and interacting with a specific remote host.
20 */ 20 */
21 public final class DesktopView extends SurfaceView { 21 public final class DesktopView extends SurfaceView {
22 22
23 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); 23 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>();
24 24
25 /** The parent Desktop activity. */ 25 /** The parent Desktop activity. */
26 private Desktop mDesktop; 26 private Desktop mDesktop;
27 27
28 private RenderStub mRenderStub;
29
30 private TouchInputHandler mInputHandler; 28 private TouchInputHandler mInputHandler;
31 29
32 private InputEventSender mInputEventSender; 30 private InputEventSender mInputEventSender;
33 31
34 public DesktopView(Context context, AttributeSet attributeSet) { 32 public DesktopView(Context context, AttributeSet attributeSet) {
35 super(context, attributeSet); 33 super(context, attributeSet);
36 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. 34 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
37 setFocusableInTouchMode(true); 35 setFocusableInTouchMode(true);
38 } 36 }
39 37
40 /** 38 /**
41 * Initializes the view. 39 * Initializes the view.
42 */ 40 */
43 public void init(Client client, Desktop desktop, RenderStub renderStub) { 41 public void init(Client client, Desktop desktop, RenderStub renderStub) {
44 Preconditions.isNull(mDesktop); 42 Preconditions.isNull(mDesktop);
45 Preconditions.isNull(mRenderStub); 43 Preconditions.isNull(mInputHandler);
46 Preconditions.isNull(mInputEventSender); 44 Preconditions.isNull(mInputEventSender);
47 Preconditions.notNull(desktop); 45 Preconditions.notNull(desktop);
48 Preconditions.notNull(renderStub); 46 Preconditions.notNull(renderStub);
47
49 mDesktop = desktop; 48 mDesktop = desktop;
50 mRenderStub = renderStub;
51 mInputEventSender = new InputEventSender(client); 49 mInputEventSender = new InputEventSender(client);
50 renderStub.setDesktopView(this);
51 mInputHandler = new TouchInputHandler(this, mDesktop, renderStub, mInput EventSender);
52 } 52 }
53 53
54 @Override 54 /**
55 public void onAttachedToWindow() { 55 * Destroys the view. Should be called in {@link android.app.Activity#onDest roy()}.
56 Preconditions.isNull(mInputHandler); 56 */
57 super.onAttachedToWindow(); 57 public void destroy() {
58 mRenderStub.setDesktopView(this);
59 mInputHandler = new TouchInputHandler(this, mDesktop, mRenderStub, mInpu tEventSender);
60 }
61
62 @Override
63 public void onDetachedFromWindow() {
64 mInputHandler.detachEventListeners(); 58 mInputHandler.detachEventListeners();
65 super.onDetachedFromWindow();
66 } 59 }
67 60
68 // TODO(yuweih): move showActionBar and showKeyboard out of this class. 61 // TODO(yuweih): move showActionBar and showKeyboard out of this class.
69 /** Shows the action bar. */ 62 /** Shows the action bar. */
70 public final void showActionBar() { 63 public final void showActionBar() {
71 mDesktop.showSystemUi(); 64 mDesktop.showSystemUi();
72 } 65 }
73 66
74 /** Shows the software keyboard. */ 67 /** Shows the software keyboard. */
75 public final void showKeyboard() { 68 public final void showKeyboard() {
(...skipping 26 matching lines...) Expand all
102 } 95 }
103 96
104 /** Called whenever the user attempts to touch the canvas. */ 97 /** Called whenever the user attempts to touch the canvas. */
105 @Override 98 @Override
106 public final boolean onTouchEvent(MotionEvent event) { 99 public final boolean onTouchEvent(MotionEvent event) {
107 TouchEventParameter parameter = new TouchEventParameter(event); 100 TouchEventParameter parameter = new TouchEventParameter(event);
108 mOnTouch.raise(parameter); 101 mOnTouch.raise(parameter);
109 return parameter.handled; 102 return parameter.handled;
110 } 103 }
111 } 104 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Desktop.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698