ShadowTabSpec.java revision 99fafb79bf98b7aa1946bbda1f0a225cefa2d35d
1package com.xtremelabs.robolectric.shadows;
2
3import android.content.Intent;
4import android.graphics.drawable.Drawable;
5import android.view.View;
6import android.widget.TabHost;
7import android.widget.TabHost.TabContentFactory;
8import com.xtremelabs.robolectric.internal.Implementation;
9import com.xtremelabs.robolectric.internal.Implements;
10import com.xtremelabs.robolectric.internal.RealObject;
11
12@SuppressWarnings({"UnusedDeclaration"})
13@Implements(TabHost.TabSpec.class)
14public class ShadowTabSpec {
15
16    @RealObject
17    TabHost.TabSpec realObject;
18    private String tag;
19    private View indicatorView;
20    private Intent intent;
21	private int viewId;
22	private View contentView;
23	private CharSequence label;
24	private Drawable icon;
25
26    /**
27     * Non-Android accessor, sets the tag on the TabSpec
28     */
29    public void setTag(String tag) {
30        this.tag = tag;
31    }
32
33    @Implementation
34    public java.lang.String getTag() {
35        return tag;
36    }
37
38    /**
39     * Non-Android accessor
40     *
41     * @return the view object set in a call to {@code TabSpec#setIndicator(View)}
42     */
43    public View getIndicatorAsView() {
44        return this.indicatorView;
45    }
46
47    public String getIndicatorLabel() {
48        return this.label.toString();
49    }
50
51    public Drawable getIndicatorIcon() {
52        return this.icon;
53    }
54
55	/**
56	 * Same as GetIndicatorLabel()
57	 * @return
58	 */
59	public String getText() {
60		return label.toString();
61	}
62    @Implementation
63    public TabHost.TabSpec setIndicator(View view) {
64        this.indicatorView = view;
65        return realObject;
66    }
67
68    @Implementation
69    public TabHost.TabSpec setIndicator(CharSequence label) {
70    	this.label = label;
71        return realObject;
72    }
73
74    @Implementation
75    public TabHost.TabSpec setIndicator(CharSequence label, Drawable icon) {
76    	this.label = label;
77    	this.icon = icon;
78        return realObject;
79    }
80
81    /**
82     * Non-Android accessor
83     *
84     * @return the intent object set in a call to {@code TabSpec#setContent(Intent)}
85     */
86    public Intent getContentAsIntent() {
87        return intent;
88    }
89
90    @Implementation
91    public android.widget.TabHost.TabSpec setContent(Intent intent) {
92        this.intent = intent;
93        return realObject;
94    }
95
96    @Implementation
97    public android.widget.TabHost.TabSpec setContent(TabContentFactory factory) {
98    	contentView = factory.createTabContent(this.tag);
99        return realObject;
100    }
101
102
103    @Implementation
104    public android.widget.TabHost.TabSpec setContent(int viewId) {
105    	this.viewId = viewId;
106        return realObject;
107    }
108
109    public int getContentViewId() {
110    	return viewId;
111    }
112
113    public View getContentView() {
114    	return contentView;
115    }
116
117}
118