10246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu/*
20246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * Copyright (C) 2014 The Android Open Source Project
30246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu *
40246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
50246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * in compliance with the License. You may obtain a copy of the License at
60246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu *
70246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * http://www.apache.org/licenses/LICENSE-2.0
80246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu *
90246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * Unless required by applicable law or agreed to in writing, software distributed under the License
100246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
110246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * or implied. See the License for the specific language governing permissions and limitations under
120246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu * the License.
130246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu */
140246318f27a905a31df5a8af445cfe67d31dfb68Dake Gupackage android.support.v17.leanback.widget;
150246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu
160246318f27a905a31df5a8af445cfe67d31dfb68Dake Guimport android.support.v17.leanback.widget.ItemAlignmentFacet.ItemAlignmentDef;
170246318f27a905a31df5a8af445cfe67d31dfb68Dake Guimport android.support.v7.widget.RecyclerView;
180246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu
190246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu/**
20ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * Interface for receiving notification when a child of this ViewGroup has been selected.
21ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * There are two methods:
22ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * <li>
23ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *     {link {@link #onChildViewHolderSelected(RecyclerView, RecyclerView.ViewHolder, int, int)}}
24ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *     is called when the view holder is about to be selected.  The listener could change size
25ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *     of the view holder in this callback.
26ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * </li>
27ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * <li>
28ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *     {link {@link #onChildViewHolderSelectedAndPositioned(RecyclerView, RecyclerView.ViewHolder,
29ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *     int, int)} is called when view holder has been selected and laid out in RecyclerView.
30ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu *
31ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu * </li>
320246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu */
330246318f27a905a31df5a8af445cfe67d31dfb68Dake Gupublic abstract class OnChildViewHolderSelectedListener {
340246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu    /**
35ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * Callback method to be invoked when a child of this ViewGroup has been selected. Listener
36ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * might change the size of the child and the position of the child is not finalized. To get
37ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * the final layout position of child, overide {@link #onChildViewHolderSelectedAndPositioned(
38ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * RecyclerView, RecyclerView.ViewHolder, int, int)}.
390246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     *
400246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     * @param parent The RecyclerView where the selection happened.
410246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     * @param child The ViewHolder within the RecyclerView that is selected, or null if no
420246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     *        view is selected.
430246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     * @param position The position of the view in the adapter, or NO_POSITION
440246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     *        if no view is selected.
450246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     * @param subposition The index of which {@link ItemAlignmentDef} being used,
460246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     *                    0 if there is no ItemAlignmentDef defined for the item.
470246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu     */
480246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu    public void onChildViewHolderSelected(RecyclerView parent, RecyclerView.ViewHolder child,
490246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu            int position, int subposition) {
500246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu    }
51ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu
52ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu    /**
53ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * Callback method to be invoked when a child of this ViewGroup has been selected and
54ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * positioned.
55ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     *
56ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * @param parent The RecyclerView where the selection happened.
57ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * @param child The ViewHolder within the RecyclerView that is selected, or null if no
58ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     *        view is selected.
59ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * @param position The position of the view in the adapter, or NO_POSITION
60ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     *        if no view is selected.
61ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     * @param subposition The index of which {@link ItemAlignmentDef} being used,
62ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     *                    0 if there is no ItemAlignmentDef defined for the item.
63ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu     */
64ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu    public void onChildViewHolderSelectedAndPositioned(RecyclerView parent,
65ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu            RecyclerView.ViewHolder child, int position, int subposition) {
66ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu    }
67ae746be7c46297b910a99c07697e33e3a5fd7facDake Gu
680246318f27a905a31df5a8af445cfe67d31dfb68Dake Gu}
69