1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.content.Intent;
4 import android.graphics.drawable.Drawable;
5 import android.view.View;
6 import android.widget.TabHost;
7 import android.widget.TabHost.TabContentFactory;
8 import com.xtremelabs.robolectric.internal.Implementation;
9 import com.xtremelabs.robolectric.internal.Implements;
10 import com.xtremelabs.robolectric.internal.RealObject;
11 
12 @SuppressWarnings({"UnusedDeclaration"})
13 @Implements(TabHost.TabSpec.class)
14 public 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      */
setTag(String tag)29     public void setTag(String tag) {
30         this.tag = tag;
31     }
32 
33     @Implementation
getTag()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      */
getIndicatorAsView()43     public View getIndicatorAsView() {
44         return this.indicatorView;
45     }
46 
getIndicatorLabel()47     public String getIndicatorLabel() {
48         return this.label.toString();
49     }
50 
getIndicatorIcon()51     public Drawable getIndicatorIcon() {
52         return this.icon;
53     }
54 
55 	/**
56 	 * Same as GetIndicatorLabel()
57 	 * @return
58 	 */
getText()59 	public String getText() {
60 		return label.toString();
61 	}
62     @Implementation
setIndicator(View view)63     public TabHost.TabSpec setIndicator(View view) {
64         this.indicatorView = view;
65         return realObject;
66     }
67 
68     @Implementation
setIndicator(CharSequence label)69     public TabHost.TabSpec setIndicator(CharSequence label) {
70     	this.label = label;
71         return realObject;
72     }
73 
74     @Implementation
setIndicator(CharSequence label, Drawable icon)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      */
getContentAsIntent()86     public Intent getContentAsIntent() {
87         return intent;
88     }
89 
90     @Implementation
setContent(Intent intent)91     public android.widget.TabHost.TabSpec setContent(Intent intent) {
92         this.intent = intent;
93         return realObject;
94     }
95 
96     @Implementation
setContent(TabContentFactory factory)97     public android.widget.TabHost.TabSpec setContent(TabContentFactory factory) {
98     	contentView = factory.createTabContent(this.tag);
99         return realObject;
100     }
101 
102 
103     @Implementation
setContent(int viewId)104     public android.widget.TabHost.TabSpec setContent(int viewId) {
105     	this.viewId = viewId;
106         return realObject;
107     }
108 
getContentViewId()109     public int getContentViewId() {
110     	return viewId;
111     }
112 
getContentView()113     public View getContentView() {
114     	return contentView;
115     }
116 
117 }
118