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