OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.compositor.layouts; |
| 6 |
| 7 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeEvent
Filter.ScrollDirection; |
| 8 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl
er; |
| 9 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EmptyEdgeSwipe
Handler; |
| 10 |
| 11 /** |
| 12 * A {@link EdgeSwipeHandler} that takes a {@link LayoutProvider} and delegates
all swipe events |
| 13 * to {@link LayoutProvider#getActiveLayout()}. |
| 14 */ |
| 15 public class EdgeSwipeHandlerLayoutDelegate extends EmptyEdgeSwipeHandler { |
| 16 private final LayoutProvider mLayoutProvider; |
| 17 |
| 18 /** |
| 19 * Creates an instance of the {@link EdgeSwipeHandlerLayoutDelegate}. |
| 20 * @param provider A {@link LayoutProvider} instance. |
| 21 */ |
| 22 public EdgeSwipeHandlerLayoutDelegate(LayoutProvider provider) { |
| 23 mLayoutProvider = provider; |
| 24 } |
| 25 |
| 26 @Override |
| 27 public void swipeStarted(ScrollDirection direction, float x, float y) { |
| 28 if (mLayoutProvider.getActiveLayout() == null) return; |
| 29 mLayoutProvider.getActiveLayout().swipeStarted(LayoutManager.time(), dir
ection, x, y); |
| 30 } |
| 31 |
| 32 @Override |
| 33 public void swipeUpdated(float x, float y, float dx, float dy, float tx, flo
at ty) { |
| 34 if (mLayoutProvider.getActiveLayout() == null) return; |
| 35 mLayoutProvider.getActiveLayout().swipeUpdated(LayoutManager.time(), x,
y, dx, dy, tx, ty); |
| 36 } |
| 37 |
| 38 @Override |
| 39 public void swipeFinished() { |
| 40 if (mLayoutProvider.getActiveLayout() == null) return; |
| 41 mLayoutProvider.getActiveLayout().swipeFinished(LayoutManager.time()); |
| 42 } |
| 43 |
| 44 @Override |
| 45 public void swipeFlingOccurred(float x, float y, float tx, float ty, float v
x, float vy) { |
| 46 if (mLayoutProvider.getActiveLayout() == null) return; |
| 47 mLayoutProvider.getActiveLayout().swipeFlingOccurred( |
| 48 LayoutManager.time(), x, y, tx, ty, vx, vy); |
| 49 } |
| 50 } |
OLD | NEW |