1 /* 2 * Copyright (C) 2015 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.setupwizardlib.util; 18 19 import android.widget.ScrollView; 20 21 import com.android.setupwizardlib.view.BottomScrollView; 22 import com.android.setupwizardlib.view.NavigationBar; 23 24 /** 25 * Add this helper to require the scroll view to be scrolled to the bottom, making sure that the 26 * user sees all content on the screen. This will change the navigation bar to show the more button 27 * instead of the next button when there is more content to be seen. When the more button is 28 * clicked, the scroll view will be scrolled one page down. 29 */ 30 public class RequireScrollHelper extends AbstractRequireScrollHelper 31 implements BottomScrollView.BottomScrollListener { 32 33 public static void requireScroll(NavigationBar navigationBar, BottomScrollView scrollView) { 34 new RequireScrollHelper(navigationBar, scrollView).requireScroll(); 35 } 36 37 private final BottomScrollView mScrollView; 38 39 private RequireScrollHelper(NavigationBar navigationBar, BottomScrollView scrollView) { 40 super(navigationBar); 41 mScrollView = scrollView; 42 } 43 44 @Override 45 protected void requireScroll() { 46 super.requireScroll(); 47 mScrollView.setBottomScrollListener(this); 48 } 49 50 @Override 51 protected void pageScrollDown() { 52 mScrollView.pageScroll(ScrollView.FOCUS_DOWN); 53 } 54 55 @Override 56 public void onScrolledToBottom() { 57 notifyScrolledToBottom(); 58 } 59 60 @Override 61 public void onRequiresScroll() { 62 notifyRequiresScroll(); 63 } 64 } 65