| // Copyright 2019 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| package org.chromium.chrome.browser.keyboard_accessory.sheet_component; |
| |
| import android.content.Context; |
| import android.support.annotation.NonNull; |
| import android.support.annotation.Nullable; |
| import android.support.v4.view.ViewPager; |
| import android.util.AttributeSet; |
| import android.view.MotionEvent; |
| |
| /** |
| * This ViewPager disables all animations - swipes and smooth transitions. |
| */ |
| class NoSwipeViewPager extends ViewPager { |
| public NoSwipeViewPager(@NonNull Context context, @Nullable AttributeSet attrs) { |
| super(context, attrs); |
| } |
| |
| @Override |
| public boolean onTouchEvent(MotionEvent event) { |
| return false; |
| } |
| |
| @Override |
| public boolean onInterceptTouchEvent(MotionEvent event) { |
| return false; |
| } |
| |
| @Override |
| public void setCurrentItem(int item) { |
| // By default, setCurrentItem would enable smoothScroll. Disable it instead: |
| super.setCurrentItem(item, false); |
| } |
| } |