• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     FIRST_EXPANDED(new int[]{android.R.attr.state_first, android.R.attr.state_expanded}),
25     MIDDLE(new int[]{android.R.attr.state_middle}),
26     MIDDLE_EXPANDED(new int[]{android.R.attr.state_middle, android.R.attr.state_expanded}),
27     LAST(new int[]{android.R.attr.state_last}),
28     SINGLE(new int[]{android.R.attr.state_single});
29 
30     final int[] mStateSet;
31 
WidgetsListDrawableState(int[] stateSet)32     WidgetsListDrawableState(int[] stateSet) {
33         mStateSet = stateSet;
34     }
35 
obtain(boolean isFirst, boolean isLast, boolean isExpanded)36     static WidgetsListDrawableState obtain(boolean isFirst, boolean isLast, boolean isExpanded) {
37         if (isFirst && isLast) return SINGLE;
38         if (isFirst && isExpanded) return FIRST_EXPANDED;
39         if (isFirst) return FIRST;
40         if (isLast) return LAST;
41         if (isExpanded) return MIDDLE_EXPANDED;
42         return MIDDLE;
43     }
44 }
45