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 */
14package android.support.v17.leanback.widget;
15
16/**
17 * Interface for receiving notification when a row or item becomes selected.
18 */
19public interface OnItemViewSelectedListener {
20    /**
21     * Called when the a row or a new item becomes selected.  The concept of current selection
22     * is different than focus.  Row or item can be selected even they don't have focus.
23     * Having the concept of selection will allow developer to switch background to selected
24     * item or selected row when user selects rows outside row UI (e.g. headers left of
25     * rows).
26     * <p>
27     * For a none {@link ListRow} case,  parameter item is always null.  Event is fired when
28     * selection changes between rows, regardless if row view has focus or not.
29     * <p>
30     * For a {@link ListRow} case, parameter item can be null if the list row is empty.
31     * </p>
32     * <p>
33     * In the case of a grid, the row parameter is always null.
34     * </p>
35     * <li>
36     * Row has focus: event is fired when focus changes between child of the row.
37     * </li>
38     * <li>
39     * None of the row has focus: the event is fired with the current selected row and last
40     * focused item in the row.
41     * </li>
42     *
43     * @param itemViewHolder The view holder of item that is currently selected.
44     * @param item The item that is currently selected.
45     * @param rowViewHolder The view holder of row that is currently selected.
46     * @param row The row that is currently selected.
47     */
48    public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
49            RowPresenter.ViewHolder rowViewHolder, Row row);
50}
51