blob: 40e8884647e414e7585d55c5aca68a97e5b050ab [file] [log] [blame]
Alan Viverette4cda5b72013-08-28 17:53:41 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher3;
18
Bjorn Bringertb66773c2013-09-25 16:12:24 +010019import android.support.v4.widget.AutoScrollHelper;
Alan Viverette4cda5b72013-08-28 17:53:41 -070020import android.widget.ScrollView;
21
22/**
23 * An implementation of {@link AutoScrollHelper} that knows how to scroll
24 * through a {@link Folder}.
25 */
26public class FolderAutoScrollHelper extends AutoScrollHelper {
27 private static final float MAX_SCROLL_VELOCITY = 1500f;
28
29 private final ScrollView mTarget;
30
31 public FolderAutoScrollHelper(ScrollView target) {
32 super(target);
33
34 mTarget = target;
35
36 setActivationDelay(0);
Mindy Pereirae886ee12013-09-04 14:32:02 -070037 setEdgeType(EDGE_TYPE_INSIDE_EXTEND);
Alan Viverette4cda5b72013-08-28 17:53:41 -070038 setExclusive(true);
39 setMaximumVelocity(MAX_SCROLL_VELOCITY, MAX_SCROLL_VELOCITY);
Mindy Pereira33d143a2013-09-06 14:03:41 -070040 setRampDownDuration(0);
41 setRampUpDuration(0);
Alan Viverette4cda5b72013-08-28 17:53:41 -070042 }
43
44 @Override
45 public void scrollTargetBy(int deltaX, int deltaY) {
46 mTarget.scrollBy(deltaX, deltaY);
47 }
48
49 @Override
50 public boolean canTargetScrollHorizontally(int direction) {
51 // List do not scroll horizontally.
52 return false;
53 }
54
55 @Override
56 public boolean canTargetScrollVertically(int direction) {
57 return mTarget.canScrollVertically(direction);
58 }
59}