Action.java revision e652714f2fcc876de6f168b28dd03bfc22e1cb96
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
16import android.graphics.drawable.Drawable;
17
18import static android.support.v17.leanback.widget.ObjectAdapter.NO_ID;
19
20/**
21 * An action that can be shown on a details page. It contains one or two lines
22 * of text and an optional image.
23 */
24public class Action {
25
26    private long mId = NO_ID;
27    private Drawable mIcon;
28    private CharSequence mLabel1;
29    private CharSequence mLabel2;
30
31    public Action(long id) {
32        this(id, "");
33    }
34
35    public Action(long id, CharSequence label) {
36        this(id, label, null);
37    }
38
39    public Action(long id, CharSequence label1, CharSequence label2) {
40        this(id, label1, label2, null);
41    }
42
43    public Action(long id, CharSequence label1, CharSequence label2, Drawable icon) {
44        setId(id);
45        setLabel1(label1);
46        setLabel2(label2);
47        setIcon(icon);
48    }
49
50    /**
51     * Set id for this action.
52     */
53    public final void setId(long id) {
54        mId = id;
55    }
56
57    /**
58     * Returns the id for this action.
59     */
60    public final long getId() {
61        return mId;
62    }
63
64    /**
65     * Set the first line label for this action.
66     */
67    public final void setLabel1(CharSequence label) {
68        mLabel1 = label;
69    }
70
71    /**
72     * Returns the first line label for this action.
73     */
74    public final CharSequence getLabel1() {
75        return mLabel1;
76    }
77
78    /**
79     * Set the second line label for this action.
80     */
81    public final void setLabel2(CharSequence label) {
82        mLabel2 = label;
83    }
84
85    /**
86     * Returns the second line label for this action.
87     */
88    public final CharSequence getLabel2() {
89        return mLabel2;
90    }
91
92    /**
93     * Set the icon drawable for this action.
94     */
95    public final void setIcon(Drawable icon) {
96        mIcon = icon;
97    }
98
99    /**
100     * Returns the icon drawable for this action.
101     */
102    public final Drawable getIcon() {
103        return mIcon;
104    }
105}
106