• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 
17 package com.android.launcher3.allapps;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.view.MotionEvent;
22 
23 import com.android.launcher3.views.RecyclerViewFastScroller;
24 
25 /**
26  * Extension of {@link RecyclerViewFastScroller} to be used in landscape layout.
27  */
28 public class LandscapeFastScroller extends RecyclerViewFastScroller {
29 
LandscapeFastScroller(Context context)30     public LandscapeFastScroller(Context context) {
31         super(context);
32     }
33 
LandscapeFastScroller(Context context, AttributeSet attrs)34     public LandscapeFastScroller(Context context, AttributeSet attrs) {
35         super(context, attrs);
36     }
37 
LandscapeFastScroller(Context context, AttributeSet attrs, int defStyleAttr)38     public LandscapeFastScroller(Context context, AttributeSet attrs, int defStyleAttr) {
39         super(context, attrs, defStyleAttr);
40     }
41 
42     @Override
handleTouchEvent(MotionEvent ev)43     public boolean handleTouchEvent(MotionEvent ev) {
44         // We handle our own touch event, no need to handle recycler view touch delegates.
45         return false;
46     }
47 
48     @Override
onTouchEvent(MotionEvent event)49     public boolean onTouchEvent(MotionEvent event) {
50         event.offsetLocation(0, -mRv.getPaddingTop());
51         if (super.handleTouchEvent(event)) {
52             getParent().requestDisallowInterceptTouchEvent(true);
53         }
54         event.offsetLocation(0, mRv.getPaddingTop());
55         return true;
56     }
57 
58     @Override
shouldBlockIntercept(int x, int y)59     public boolean shouldBlockIntercept(int x, int y) {
60         // If the user touched the scroll bar area, block swipe
61         return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
62     }
63 }
64