1// Copyright 2014 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 5package org.chromium.chrome.browser.widget.accessibility; 6 7import android.content.Context; 8import android.util.AttributeSet; 9import android.view.MotionEvent; 10import android.widget.ListView; 11 12/** 13 * A {@link ListView} class that is responsible for providing a visual interpretation 14 * of a {@link org.chromium.chrome.browser.tabmodel.TabModel}. 15 */ 16public class AccessibilityTabModelListView extends ListView { 17 private final AccessibilityTabModelAdapter mAdapter; 18 private boolean mCanScrollVertically = true; 19 20 /** 21 * @param context The Context to build this widget under. 22 * @param attrs The AttributeSet to use to build this widget. 23 */ 24 public AccessibilityTabModelListView(Context context, AttributeSet attrs) { 25 super(context, attrs); 26 mAdapter = new AccessibilityTabModelAdapter(getContext(), this); 27 } 28 29 @Override 30 public void onFinishInflate() { 31 super.onFinishInflate(); 32 33 setAdapter(mAdapter); 34 } 35 36 @Override 37 public boolean onInterceptTouchEvent(MotionEvent e) { 38 // Ignore touch events if we're not scrolling. 39 if (!mCanScrollVertically) return false; 40 return super.onInterceptTouchEvent(e); 41 } 42 43 /** 44 * @param canScroll Whether or not the ListView should be allowed to scroll vertically. 45 */ 46 public void setCanScroll(boolean canScroll) { 47 mCanScrollVertically = canScroll; 48 } 49} 50