154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez/* 254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * Copyright 2018 The Android Open Source Project 354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * 454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * Licensed under the Apache License, Version 2.0 (the "License"); 554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * you may not use this file except in compliance with the License. 654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * You may obtain a copy of the License at 754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * 854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * http://www.apache.org/licenses/LICENSE-2.0 954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * 1054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * Unless required by applicable law or agreed to in writing, software 1154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * distributed under the License is distributed on an "AS IS" BASIS, 1254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * See the License for the specific language governing permissions and 1454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * limitations under the License. 1554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 1654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 1754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perezpackage com.android.car.media.browse; 1854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 1954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perezimport android.support.annotation.LayoutRes; 2054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 2154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez/** 2254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * Possible view types that would be used by the {@link BrowseAdapter}. 2354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 2454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perezpublic enum BrowseItemViewType { 2554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** A section header */ 26e045fd4c089bcabc4e560f4f81392d3bfcf332f4Joshua Brown HEADER(com.android.car.media.R.layout.media_browse_header_item), 2754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** A grid item including an image and a title */ 28e045fd4c089bcabc4e560f4f81392d3bfcf332f4Joshua Brown GRID_ITEM(com.android.car.media.R.layout.media_browse_grid_item, 1), 2954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** A list item including title and subtitle */ 30e045fd4c089bcabc4e560f4f81392d3bfcf332f4Joshua Brown LIST_ITEM(com.android.car.media.R.layout.media_browse_list_item), 3154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** An item in a panel of items (menu) */ 32e045fd4c089bcabc4e560f4f81392d3bfcf332f4Joshua Brown PANEL_ITEM(com.android.car.media.R.layout.media_browse_panel_item), 3354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** A footer that can be used to navigate to an expanded version of a section */ 34e045fd4c089bcabc4e560f4f81392d3bfcf332f4Joshua Brown MORE_FOOTER(com.android.car.media.R.layout.media_browse_more_footer), 3554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez ; 3654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez private final @LayoutRes int mLayoutId; 3754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez private final int mSpanSize; 3854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 3954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** 4054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * {@link BrowseItemViewType} that take the whole width of the 4154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * {@link android.support.v7.widget.RecyclerView} 4254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 4354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez BrowseItemViewType(@LayoutRes int layoutId) { 4454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez mLayoutId = layoutId; 4554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez mSpanSize = -1; 4654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez } 4754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 4854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** 4954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * {@link BrowseItemViewType} that only takes the given number of columns. 5054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 5154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez BrowseItemViewType(@LayoutRes int layoutId, int spanSize) { 5254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez mLayoutId = layoutId; 5354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez mSpanSize = spanSize; 5454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez } 5554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 5654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** 5754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * @param maxSpanSize maximum number of columns of the underlying grid 5854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * @return number of columns this view wants to use. 5954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 6054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez public int getSpanSize(int maxSpanSize) { 6154a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez return mSpanSize < 0 ? maxSpanSize : mSpanSize; 6254a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez } 6354a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez 6454a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez /** 6554a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez * @return layout that should be inflated to generate this view type. 6654a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez */ 6754a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez public @LayoutRes int getLayoutId() { 6854a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez return mLayoutId; 6954a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez } 7054a9df95716c26d7ae3a226ad506061fb9ed6e6cRoberto Perez} 71