1 /* 2 * Copyright (C) 2019 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 package com.android.tv.twopanelsettings; 17 18 import android.content.Context; 19 import android.util.AttributeSet; 20 import android.view.MotionEvent; 21 import android.widget.HorizontalScrollView; 22 23 /** A horizontal scroll view that ignores left/right key events for scrolling. */ 24 public class TwoPanelScrollView extends HorizontalScrollView { 25 TwoPanelScrollView(Context context)26 public TwoPanelScrollView(Context context) { 27 super(context); 28 } 29 TwoPanelScrollView(Context context, AttributeSet attrs)30 public TwoPanelScrollView(Context context, AttributeSet attrs) { 31 super(context, attrs); 32 } 33 34 @Override arrowScroll(int direction)35 public boolean arrowScroll(int direction) { 36 return false; 37 } 38 39 @Override onInterceptTouchEvent(MotionEvent ev)40 public boolean onInterceptTouchEvent(MotionEvent ev) { 41 switch (ev.getActionMasked()) { 42 case MotionEvent.ACTION_DOWN: 43 case MotionEvent.ACTION_MOVE: 44 case MotionEvent.ACTION_CANCEL: 45 case MotionEvent.ACTION_UP: 46 return false; 47 } 48 return super.onInterceptTouchEvent(ev); 49 } 50 51 @Override onTouchEvent(MotionEvent ev)52 public boolean onTouchEvent(MotionEvent ev) { 53 switch (ev.getActionMasked()) { 54 case MotionEvent.ACTION_DOWN: 55 case MotionEvent.ACTION_MOVE: 56 case MotionEvent.ACTION_CANCEL: 57 case MotionEvent.ACTION_UP: 58 return false; 59 } 60 return super.onInterceptTouchEvent(ev); 61 } 62 } 63