• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package android.support.v17.leanback.widget;
15 
16 import android.support.v17.leanback.widget.ItemAlignmentFacet.ItemAlignmentDef;
17 import android.support.v7.widget.RecyclerView;
18 
19 /**
20  * Interface for receiving notification when a child of this ViewGroup has been selected.
21  * There are two methods:
22  * <li>
23  *     {link {@link #onChildViewHolderSelected(RecyclerView, RecyclerView.ViewHolder, int, int)}}
24  *     is called when the view holder is about to be selected.  The listener could change size
25  *     of the view holder in this callback.
26  * </li>
27  * <li>
28  *     {link {@link #onChildViewHolderSelectedAndPositioned(RecyclerView, RecyclerView.ViewHolder,
29  *     int, int)} is called when view holder has been selected and laid out in RecyclerView.
30  *
31  * </li>
32  */
33 public abstract class OnChildViewHolderSelectedListener {
34     /**
35      * Callback method to be invoked when a child of this ViewGroup has been selected. Listener
36      * might change the size of the child and the position of the child is not finalized. To get
37      * the final layout position of child, overide {@link #onChildViewHolderSelectedAndPositioned(
38      * RecyclerView, RecyclerView.ViewHolder, int, int)}.
39      *
40      * @param parent The RecyclerView where the selection happened.
41      * @param child The ViewHolder within the RecyclerView that is selected, or null if no
42      *        view is selected.
43      * @param position The position of the view in the adapter, or NO_POSITION
44      *        if no view is selected.
45      * @param subposition The index of which {@link ItemAlignmentDef} being used,
46      *                    0 if there is no ItemAlignmentDef defined for the item.
47      */
onChildViewHolderSelected(RecyclerView parent, RecyclerView.ViewHolder child, int position, int subposition)48     public void onChildViewHolderSelected(RecyclerView parent, RecyclerView.ViewHolder child,
49             int position, int subposition) {
50     }
51 
52     /**
53      * Callback method to be invoked when a child of this ViewGroup has been selected and
54      * positioned.
55      *
56      * @param parent The RecyclerView where the selection happened.
57      * @param child The ViewHolder within the RecyclerView that is selected, or null if no
58      *        view is selected.
59      * @param position The position of the view in the adapter, or NO_POSITION
60      *        if no view is selected.
61      * @param subposition The index of which {@link ItemAlignmentDef} being used,
62      *                    0 if there is no ItemAlignmentDef defined for the item.
63      */
onChildViewHolderSelectedAndPositioned(RecyclerView parent, RecyclerView.ViewHolder child, int position, int subposition)64     public void onChildViewHolderSelectedAndPositioned(RecyclerView parent,
65             RecyclerView.ViewHolder child, int position, int subposition) {
66     }
67 
68 }
69