1 /* 2 * Copyright (C) 2018 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.allapps; 17 18 import android.view.View; 19 20 /** 21 * A abstract representation of a row in all-apps view 22 */ 23 public interface FloatingHeaderRow { 24 25 FloatingHeaderRow[] NO_ROWS = new FloatingHeaderRow[0]; 26 setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, boolean tabsHidden)27 void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, boolean tabsHidden); 28 getExpectedHeight()29 int getExpectedHeight(); 30 31 /** 32 * Returns true if the row should draw based on its current position and layout. 33 */ shouldDraw()34 boolean shouldDraw(); 35 36 /** 37 * Returns true if the view has anything worth drawing. This is different than 38 * {@link #shouldDraw()} as this is called earlier in the layout to determine the view 39 * position. 40 */ hasVisibleContent()41 boolean hasVisibleContent(); 42 43 /** 44 * Scrolls the content vertically. 45 * @param scroll scrolled distance in pixels for active recyclerview. 46 * @param isScrolledOut bool to determine if row is scrolled out of view 47 */ setVerticalScroll(int scroll, boolean isScrolledOut)48 void setVerticalScroll(int scroll, boolean isScrolledOut); 49 getTypeClass()50 Class<? extends FloatingHeaderRow> getTypeClass(); 51 52 /** 53 * Returns a child that has focus to be launched by the IME. 54 */ getFocusedChild()55 View getFocusedChild(); 56 57 /** 58 * Returns true if view is currently visible 59 */ isVisible()60 default boolean isVisible() { 61 return shouldDraw(); 62 } 63 } 64