1 /* 2 * Copyright (C) 2016 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.launcher3.pageindicators; 17 18 import java.util.function.Consumer; 19 20 /** 21 * Base class for a page indicator. 22 */ 23 public interface PageIndicator { 24 setScroll(int currentScroll, int totalScroll)25 void setScroll(int currentScroll, int totalScroll); 26 setActiveMarker(int activePage)27 void setActiveMarker(int activePage); 28 setMarkersCount(int numMarkers)29 void setMarkersCount(int numMarkers); 30 31 /** 32 * This is only going to be used by the FolderPagedView's PageIndicator. A refactor is planned 33 * to separate the two purposes of this class, but in the meantime, this indicator will serve to 34 * let the folder snap to the page of its click, and also tell the PageIndicator not to draw 35 * arrows if the click listener is null (at least until after this is refactored). 36 */ setArrowClickListener(Consumer<Direction> listener)37 void setArrowClickListener(Consumer<Direction> listener); 38 39 /** 40 * Sets a flag indicating whether to pause scroll. 41 * <p>Should be set to {@code true} while the screen is binding or new data is being applied, 42 * and to {@code false} once done. This prevents animation conflicts due to scrolling during 43 * those periods.</p> 44 */ setPauseScroll(boolean pause, boolean isTwoPanels)45 default void setPauseScroll(boolean pause, boolean isTwoPanels) { 46 // No-op by default 47 } 48 49 /** 50 * Sets the flag if the Page Indicator should autohide. 51 */ setShouldAutoHide(boolean shouldAutoHide)52 default void setShouldAutoHide(boolean shouldAutoHide) { 53 // No-op by default 54 } 55 56 /** 57 * Pauses all currently running animations. 58 */ pauseAnimations()59 default void pauseAnimations() { 60 // No-op by default 61 } 62 63 /** 64 * Force-ends all currently running or paused animations. 65 */ skipAnimationsToEnd()66 default void skipAnimationsToEnd() { 67 // No-op by default 68 } 69 70 /** 71 * Sets the paint color. 72 */ setPaintColor(int color)73 default void setPaintColor(int color) { 74 // No-op by default 75 } 76 } 77