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.widget.picker; 17 18 /** 19 * Different possible list position states for an item in the widgets list to have. Note that only 20 * headers use the expanded state. 21 */ 22 enum WidgetsListDrawableState { 23 FIRST(new int[]{android.R.attr.state_first}), 24 MIDDLE(new int[]{android.R.attr.state_middle}), 25 LAST(new int[]{android.R.attr.state_last}), 26 SINGLE(new int[]{android.R.attr.state_single}); 27 28 final int[] mStateSet; 29 WidgetsListDrawableState(int[] stateSet)30 WidgetsListDrawableState(int[] stateSet) { 31 mStateSet = stateSet; 32 } 33 obtain(boolean isFirst, boolean isLast)34 static WidgetsListDrawableState obtain(boolean isFirst, boolean isLast) { 35 if (isFirst && isLast) return SINGLE; 36 if (isFirst) return FIRST; 37 if (isLast) return LAST; 38 return MIDDLE; 39 } 40 } 41