1/*
2 * Copyright 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.example.android.tabcompat.lib;
18
19import android.graphics.drawable.Drawable;
20import android.support.v4.app.Fragment;
21import android.support.v4.app.FragmentActivity;
22
23/**
24 * A base implementation of the {@link CompatTab} interface.
25 */
26public class CompatTabEclair extends CompatTab {
27    private CompatTabListener mCallback;
28    private CharSequence mText;
29    private Drawable mIcon;
30    private Fragment mFragment;
31
32    protected CompatTabEclair(FragmentActivity activity, String tag) {
33        super(activity, tag);
34    }
35
36    @Override
37    public CompatTab setText(int resId) {
38        mText = mActivity.getResources().getText(resId);
39        return this;
40    }
41
42    @Override
43    public CompatTab setIcon(int resId) {
44        mIcon = mActivity.getResources().getDrawable(resId);
45        return this;
46    }
47
48    @Override
49    public CompatTab setTabListener(CompatTabListener callback) {
50        mCallback = callback;
51        return this;
52    }
53
54    @Override
55    public CompatTab setFragment(Fragment fragment) {
56        mFragment = fragment;
57        return this;
58    }
59
60    @Override
61    public Fragment getFragment() {
62        return mFragment;
63    }
64
65    @Override
66    public CharSequence getText() {
67        return mText;
68    }
69
70    @Override
71    public Drawable getIcon() {
72        return mIcon;
73    }
74
75    @Override
76    public Object getTab() {
77        return null;
78    }
79
80    @Override
81    public CompatTabListener getCallback() {
82        return mCallback;
83    }
84}
85