1 /*
2  * Copyright 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 
17 package androidx.car.widget;
18 
19 import java.util.Collection;
20 
21 /**
22  * An interface that you can implement on your Adapter to enable support for Alpha-Jump.
23  */
24 public interface IAlphaJumpAdapter {
25     /**
26      * A bucket represents a "button" in the alpha-jump menu.
27      */
28     interface Bucket {
29         /**
30          * Return true if the bucket is empty (and therefore the button should be displayed
31          * disabled).
32          */
isEmpty()33         boolean isEmpty();
34 
35         /**
36          * Return the label for this bucket, that is displayed at the text to the user.
37          */
getLabel()38         CharSequence getLabel();
39 
40         /**
41          * Return the index of the first item that this bucket matches in the list.
42          */
getIndex()43         int getIndex();
44     }
45 
46     /**
47      * Generate and populate the buckets used to populate the alpha-jump menu.
48      */
getAlphaJumpBuckets()49     Collection<Bucket> getAlphaJumpBuckets();
50 
51     /**
52      * Called every time the alpha-jump menu is entered.
53      */
onAlphaJumpEnter()54     void onAlphaJumpEnter();
55 
56     /**
57      * Called every time the alpha-jump menu is left.
58      *
59      * @param bucket The {@link Bucket} that the user clicked on, and should be jumped to.
60      */
onAlphaJumpLeave(Bucket bucket)61     void onAlphaJumpLeave(Bucket bucket);
62 }
63