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