OLD | NEW |
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.chrome.browser.compositor.layouts.eventfilter; | 5 package org.chromium.chrome.browser.compositor.layouts.eventfilter; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.view.MotionEvent; | 8 import android.view.MotionEvent; |
9 | 9 |
10 import java.util.Arrays; | 10 import java.util.Arrays; |
11 | 11 |
12 /** | 12 /** |
13 * A {@link CascadeEventFilter} delegates all the events coming its way to anoth
er filter. | 13 * A {@link CascadeEventFilter} delegates all the events coming its way to anoth
er filter. |
14 */ | 14 */ |
15 public class CascadeEventFilter extends EventFilter { | 15 public class CascadeEventFilter extends EventFilter { |
16 private EventFilter[] mDelegates; | 16 private EventFilter[] mDelegates; |
17 private EventFilter mActiveDelegate = null; | 17 private EventFilter mActiveDelegate; |
18 | 18 |
19 /** | 19 /** |
20 * Creates a {@link CascadeEventFilter}. | 20 * Creates a {@link CascadeEventFilter}. |
21 * | 21 * |
22 * The delegates will be queried in the order specified in this list (0 -> c
ount). Once a | 22 * The delegates will be queried in the order specified in this list (0 -> c
ount). Once a |
23 * delegate takes ownership of the event by returning {@code true} from | 23 * delegate takes ownership of the event by returning {@code true} from |
24 * {@link EventFilter#onInterceptTouchEventInternal(MotionEvent, boolean)} i
t will get all | 24 * {@link EventFilter#onInterceptTouchEventInternal(MotionEvent, boolean)} i
t will get all |
25 * subsequent events for the same gesture to | 25 * subsequent events for the same gesture to |
26 * {@link EventFilter#onTouchEventInternal(MotionEvent)}. | 26 * {@link EventFilter#onTouchEventInternal(MotionEvent)}. |
27 * | 27 * |
(...skipping 27 matching lines...) Expand all Loading... |
55 public boolean onTouchEventInternal(MotionEvent e) { | 55 public boolean onTouchEventInternal(MotionEvent e) { |
56 if (mActiveDelegate != null) { | 56 if (mActiveDelegate != null) { |
57 if (mActiveDelegate.autoOffsetEvents()) { | 57 if (mActiveDelegate.autoOffsetEvents()) { |
58 e.offsetLocation(mCurrentTouchOffsetX, mCurrentTouchOffsetY); | 58 e.offsetLocation(mCurrentTouchOffsetX, mCurrentTouchOffsetY); |
59 } | 59 } |
60 return mActiveDelegate.onTouchEventInternal(e); | 60 return mActiveDelegate.onTouchEventInternal(e); |
61 } | 61 } |
62 return false; | 62 return false; |
63 } | 63 } |
64 } | 64 } |
OLD | NEW |