1 /* 2 * Copyright (C) 2021 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.LayoutInflater; 19 import android.view.ViewGroup; 20 21 /** 22 * A UI expansion wrapper providing for providing dynamic recyclerview items 23 */ 24 public abstract class BaseAdapterProvider { 25 26 /** 27 * Returns whether or not viewType can be handled by searchProvider 28 */ isViewSupported(int viewType)29 public abstract boolean isViewSupported(int viewType); 30 31 /** 32 * Called from RecyclerView.Adapter#onBindViewHolder 33 */ onBindView(AllAppsGridAdapter.ViewHolder holder, int position)34 public abstract void onBindView(AllAppsGridAdapter.ViewHolder holder, int position); 35 36 /** 37 * Called from RecyclerView.Adapter#onCreateViewHolder 38 */ onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup parent, int viewType)39 public abstract AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, 40 ViewGroup parent, int viewType); 41 42 /** 43 * Returns supported item per row combinations supported 44 */ getSupportedItemsPerRowArray()45 public int[] getSupportedItemsPerRowArray() { 46 return new int[]{}; 47 } 48 49 /** 50 * Returns how many cells a view should span 51 */ getItemsPerRow(int viewType, int appsPerRow)52 public int getItemsPerRow(int viewType, int appsPerRow) { 53 return appsPerRow; 54 } 55 56 } 57