blob: 6b5240990e9946e3a4871bd8baeeacefc34e9587 [file] [log] [blame]
Adam Powell89e06452010-06-23 20:24:52 -07001/*
2 * Copyright (C) 2010 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.android.internal.app;
18
Adam Powell2c9c9fe2010-07-16 10:17:57 -070019import com.android.internal.view.menu.MenuBuilder;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070020import com.android.internal.view.menu.MenuPopupHelper;
21import com.android.internal.view.menu.SubMenuBuilder;
Adam Powell89e06452010-06-23 20:24:52 -070022import com.android.internal.widget.ActionBarContextView;
23import com.android.internal.widget.ActionBarView;
24
25import android.app.ActionBar;
Adam Powell661c9082010-07-02 10:09:44 -070026import android.app.Activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070027import android.app.Dialog;
Adam Powell661c9082010-07-02 10:09:44 -070028import android.app.Fragment;
29import android.app.FragmentTransaction;
Adam Powelldec9dfd2010-08-09 15:27:54 -070030import android.content.Context;
Adam Powell89e06452010-06-23 20:24:52 -070031import android.graphics.drawable.Drawable;
Adam Powell0e94b512010-06-29 17:58:20 -070032import android.os.Handler;
Adam Powell6e346362010-07-23 10:18:23 -070033import android.view.ActionMode;
Adam Powell89e06452010-06-23 20:24:52 -070034import android.view.Menu;
Adam Powell9168f0b2010-08-02 15:46:24 -070035import android.view.MenuInflater;
Adam Powell89e06452010-06-23 20:24:52 -070036import android.view.MenuItem;
37import android.view.View;
38import android.widget.LinearLayout;
39import android.widget.SpinnerAdapter;
40import android.widget.ViewAnimator;
41
Adam Powell29ed7572010-07-14 16:24:56 -070042import java.lang.ref.WeakReference;
Adam Powell661c9082010-07-02 10:09:44 -070043import java.util.ArrayList;
44
Adam Powell89e06452010-06-23 20:24:52 -070045/**
46 * ActionBarImpl is the ActionBar implementation used
47 * by devices of all screen sizes. If it detects a compatible decor,
48 * it will split contextual modes across both the ActionBarView at
49 * the top of the screen and a horizontal LinearLayout at the bottom
50 * which is normally hidden.
51 */
52public class ActionBarImpl extends ActionBar {
53 private static final int NORMAL_VIEW = 0;
54 private static final int CONTEXT_VIEW = 1;
55
Adam Powell661c9082010-07-02 10:09:44 -070056 private static final int TAB_SWITCH_SHOW_HIDE = 0;
57 private static final int TAB_SWITCH_ADD_REMOVE = 1;
58
Adam Powelldec9dfd2010-08-09 15:27:54 -070059 private Context mContext;
Adam Powell661c9082010-07-02 10:09:44 -070060 private Activity mActivity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070061 private Dialog mDialog;
Adam Powell661c9082010-07-02 10:09:44 -070062
Adam Powell89e06452010-06-23 20:24:52 -070063 private ViewAnimator mAnimatorView;
64 private ActionBarView mActionView;
65 private ActionBarContextView mUpperContextView;
66 private LinearLayout mLowerContextView;
Adam Powell661c9082010-07-02 10:09:44 -070067
68 private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>();
69
70 private int mTabContainerViewId = android.R.id.content;
71 private TabImpl mSelectedTab;
72 private int mTabSwitchMode = TAB_SWITCH_ADD_REMOVE;
Adam Powell89e06452010-06-23 20:24:52 -070073
Adam Powell5d279772010-07-27 16:34:07 -070074 private ActionMode mActionMode;
Adam Powell89e06452010-06-23 20:24:52 -070075
76 private static final int CONTEXT_DISPLAY_NORMAL = 0;
77 private static final int CONTEXT_DISPLAY_SPLIT = 1;
78
79 private int mContextDisplayMode;
Adam Powell0e94b512010-06-29 17:58:20 -070080
Adam Powell3461b322010-07-14 11:34:43 -070081 private boolean mClosingContext;
82
Adam Powell0e94b512010-06-29 17:58:20 -070083 final Handler mHandler = new Handler();
84 final Runnable mCloseContext = new Runnable() {
85 public void run() {
86 mUpperContextView.closeMode();
87 if (mLowerContextView != null) {
88 mLowerContextView.removeAllViews();
89 }
Adam Powell3461b322010-07-14 11:34:43 -070090 mClosingContext = false;
Adam Powell0e94b512010-06-29 17:58:20 -070091 }
92 };
93
Adam Powell661c9082010-07-02 10:09:44 -070094 public ActionBarImpl(Activity activity) {
Adam Powell661c9082010-07-02 10:09:44 -070095 mActivity = activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070096 init(activity.getWindow().getDecorView());
97 }
98
99 public ActionBarImpl(Dialog dialog) {
100 mDialog = dialog;
101 init(dialog.getWindow().getDecorView());
102 }
103
104 private void init(View decor) {
105 mContext = decor.getContext();
Adam Powell89e06452010-06-23 20:24:52 -0700106 mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
107 mUpperContextView = (ActionBarContextView) decor.findViewById(
108 com.android.internal.R.id.action_context_bar);
109 mLowerContextView = (LinearLayout) decor.findViewById(
110 com.android.internal.R.id.lower_action_context_bar);
111 mAnimatorView = (ViewAnimator) decor.findViewById(
112 com.android.internal.R.id.action_bar_animator);
113
114 if (mActionView == null || mUpperContextView == null || mAnimatorView == null) {
115 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
116 "with a compatible window decor layout");
117 }
Adam Powell0e94b512010-06-29 17:58:20 -0700118
Adam Powell89e06452010-06-23 20:24:52 -0700119 mContextDisplayMode = mLowerContextView == null ?
120 CONTEXT_DISPLAY_NORMAL : CONTEXT_DISPLAY_SPLIT;
121 }
122
Adam Powella66c7b02010-07-28 15:28:25 -0700123 @Override
124 public void setStandardNavigationMode(int titleResId, int subtitleResId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700125 setStandardNavigationMode(mContext.getString(titleResId),
126 mContext.getString(subtitleResId));
Adam Powella66c7b02010-07-28 15:28:25 -0700127 }
128
129 @Override
130 public void setStandardNavigationMode(int titleResId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700131 setStandardNavigationMode(mContext.getString(titleResId));
Adam Powella66c7b02010-07-28 15:28:25 -0700132 }
133
134 @Override
135 public void setTitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700136 setTitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700137 }
138
139 @Override
140 public void setSubtitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700141 setSubtitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700142 }
143
Adam Powell89e06452010-06-23 20:24:52 -0700144 public void setCustomNavigationMode(View view) {
Adam Powell661c9082010-07-02 10:09:44 -0700145 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700146 mActionView.setCustomNavigationView(view);
147 mActionView.setCallback(null);
148 }
Adam Powell0e94b512010-06-29 17:58:20 -0700149
Adam Powell89e06452010-06-23 20:24:52 -0700150 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback) {
Adam Powell17809772010-07-21 13:25:11 -0700151 setDropdownNavigationMode(adapter, callback, -1);
152 }
153
154 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback,
155 int defaultSelectedPosition) {
Adam Powell661c9082010-07-02 10:09:44 -0700156 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700157 mActionView.setNavigationMode(NAVIGATION_MODE_DROPDOWN_LIST);
158 mActionView.setDropdownAdapter(adapter);
Adam Powell17809772010-07-21 13:25:11 -0700159 if (defaultSelectedPosition >= 0) {
160 mActionView.setDropdownSelectedPosition(defaultSelectedPosition);
161 }
162 mActionView.setCallback(callback);
Adam Powell89e06452010-06-23 20:24:52 -0700163 }
Adam Powell0e94b512010-06-29 17:58:20 -0700164
165 public void setStandardNavigationMode() {
Adam Powell661c9082010-07-02 10:09:44 -0700166 cleanupTabs();
Adam Powell0e94b512010-06-29 17:58:20 -0700167 mActionView.setNavigationMode(NAVIGATION_MODE_STANDARD);
168 mActionView.setCallback(null);
169 }
170
Adam Powell89e06452010-06-23 20:24:52 -0700171 public void setStandardNavigationMode(CharSequence title) {
Adam Powell661c9082010-07-02 10:09:44 -0700172 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700173 setStandardNavigationMode(title, null);
174 }
Adam Powell0e94b512010-06-29 17:58:20 -0700175
Adam Powell89e06452010-06-23 20:24:52 -0700176 public void setStandardNavigationMode(CharSequence title, CharSequence subtitle) {
Adam Powell661c9082010-07-02 10:09:44 -0700177 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700178 mActionView.setNavigationMode(NAVIGATION_MODE_STANDARD);
179 mActionView.setTitle(title);
180 mActionView.setSubtitle(subtitle);
181 mActionView.setCallback(null);
182 }
183
Adam Powell17809772010-07-21 13:25:11 -0700184 public void setSelectedNavigationItem(int position) {
185 switch (mActionView.getNavigationMode()) {
186 case NAVIGATION_MODE_TABS:
187 selectTab(mTabs.get(position));
188 break;
189 case NAVIGATION_MODE_DROPDOWN_LIST:
190 mActionView.setDropdownSelectedPosition(position);
191 break;
192 default:
193 throw new IllegalStateException(
194 "setSelectedNavigationItem not valid for current navigation mode");
195 }
196 }
197
198 public int getSelectedNavigationItem() {
199 switch (mActionView.getNavigationMode()) {
200 case NAVIGATION_MODE_TABS:
201 return mSelectedTab.getPosition();
202 case NAVIGATION_MODE_DROPDOWN_LIST:
203 return mActionView.getDropdownSelectedPosition();
204 default:
205 return -1;
206 }
207 }
208
Adam Powell661c9082010-07-02 10:09:44 -0700209 private void cleanupTabs() {
210 if (mSelectedTab != null) {
211 selectTab(null);
212 }
213 if (!mTabs.isEmpty()) {
214 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
215 final FragmentTransaction trans = mActivity.openFragmentTransaction();
216 final int tabCount = mTabs.size();
217 for (int i = 0; i < tabCount; i++) {
218 trans.remove(mTabs.get(i).getFragment());
219 }
220 trans.commit();
221 }
222 mTabs.clear();
223 }
224 }
225
Adam Powell0e94b512010-06-29 17:58:20 -0700226 public void setTitle(CharSequence title) {
227 mActionView.setTitle(title);
228 }
229
230 public void setSubtitle(CharSequence subtitle) {
231 mActionView.setSubtitle(subtitle);
232 }
233
Adam Powell89e06452010-06-23 20:24:52 -0700234 public void setDisplayOptions(int options) {
235 mActionView.setDisplayOptions(options);
236 }
Adam Powell0e94b512010-06-29 17:58:20 -0700237
Adam Powell89e06452010-06-23 20:24:52 -0700238 public void setDisplayOptions(int options, int mask) {
239 final int current = mActionView.getDisplayOptions();
240 mActionView.setDisplayOptions((options & mask) | (current & ~mask));
241 }
242
243 public void setBackgroundDrawable(Drawable d) {
244 mActionView.setBackgroundDrawable(d);
245 }
246
247 public View getCustomNavigationView() {
248 return mActionView.getCustomNavigationView();
249 }
250
251 public CharSequence getTitle() {
252 return mActionView.getTitle();
253 }
254
255 public CharSequence getSubtitle() {
256 return mActionView.getSubtitle();
257 }
258
259 public int getNavigationMode() {
260 return mActionView.getNavigationMode();
261 }
262
263 public int getDisplayOptions() {
264 return mActionView.getDisplayOptions();
265 }
266
Adam Powell5d279772010-07-27 16:34:07 -0700267 public ActionMode startActionMode(ActionMode.Callback callback) {
268 if (mActionMode != null) {
269 mActionMode.finish();
Adam Powell6e346362010-07-23 10:18:23 -0700270 }
Adam Powell3461b322010-07-14 11:34:43 -0700271
272 // Don't wait for the close context mode animation to finish.
273 if (mClosingContext) {
274 mAnimatorView.clearAnimation();
275 mHandler.removeCallbacks(mCloseContext);
276 mCloseContext.run();
277 }
278
Adam Powell5d279772010-07-27 16:34:07 -0700279 ActionMode mode = new ActionModeImpl(callback);
Adam Powell6e346362010-07-23 10:18:23 -0700280 if (callback.onCreateActionMode(mode, mode.getMenu())) {
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700281 mode.invalidate();
282 mUpperContextView.initForMode(mode);
Adam Powell89e06452010-06-23 20:24:52 -0700283 mAnimatorView.setDisplayedChild(CONTEXT_VIEW);
284 if (mLowerContextView != null) {
285 // TODO animate this
286 mLowerContextView.setVisibility(View.VISIBLE);
287 }
Adam Powell5d279772010-07-27 16:34:07 -0700288 mActionMode = mode;
Adam Powellac695c62010-07-20 18:19:27 -0700289 return mode;
Adam Powell89e06452010-06-23 20:24:52 -0700290 }
Adam Powellac695c62010-07-20 18:19:27 -0700291 return null;
Adam Powell89e06452010-06-23 20:24:52 -0700292 }
293
Adam Powell661c9082010-07-02 10:09:44 -0700294 private void configureTab(Tab tab, int position) {
295 final TabImpl tabi = (TabImpl) tab;
296 final boolean isFirstTab = mTabs.isEmpty();
297 final FragmentTransaction trans = mActivity.openFragmentTransaction();
298 final Fragment frag = tabi.getFragment();
299
300 tabi.setPosition(position);
301 mTabs.add(position, tabi);
302
303 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
304 if (!frag.isAdded()) {
305 trans.add(mTabContainerViewId, frag);
306 }
307 }
308
309 if (isFirstTab) {
310 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
311 trans.show(frag);
312 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
313 trans.add(mTabContainerViewId, frag);
314 }
315 mSelectedTab = tabi;
316 } else {
317 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
318 trans.hide(frag);
319 }
320 }
321 trans.commit();
322 }
323
324 @Override
325 public void addTab(Tab tab) {
326 mActionView.addTab(tab);
327 configureTab(tab, mTabs.size());
328 }
329
330 @Override
331 public void insertTab(Tab tab, int position) {
332 mActionView.insertTab(tab, position);
333 configureTab(tab, position);
334 }
335
336 @Override
337 public Tab newTab() {
338 return new TabImpl();
339 }
340
341 @Override
342 public void removeTab(Tab tab) {
343 removeTabAt(tab.getPosition());
344 }
345
346 @Override
347 public void removeTabAt(int position) {
348 mActionView.removeTabAt(position);
349 mTabs.remove(position);
350
351 final int newTabCount = mTabs.size();
352 for (int i = position; i < newTabCount; i++) {
353 mTabs.get(i).setPosition(i);
354 }
355
356 selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
357 }
358
359 @Override
360 public void setTabNavigationMode() {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700361 if (mActivity == null) {
362 throw new IllegalStateException(
363 "Tab navigation mode cannot be used outside of an Activity");
364 }
Adam Powell661c9082010-07-02 10:09:44 -0700365 mActionView.setNavigationMode(NAVIGATION_MODE_TABS);
366 }
367
368 @Override
369 public void setTabNavigationMode(int containerViewId) {
370 mTabContainerViewId = containerViewId;
371 setTabNavigationMode();
372 }
373
374 @Override
375 public void selectTab(Tab tab) {
376 if (mSelectedTab == tab) {
377 return;
378 }
379
380 mActionView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
381 final FragmentTransaction trans = mActivity.openFragmentTransaction();
382 if (mSelectedTab != null) {
383 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
384 trans.hide(mSelectedTab.getFragment());
385 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
386 trans.remove(mSelectedTab.getFragment());
387 }
388 }
389 if (tab != null) {
390 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
391 trans.show(tab.getFragment());
392 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
393 trans.add(mTabContainerViewId, tab.getFragment());
394 }
395 }
396 mSelectedTab = (TabImpl) tab;
397 trans.commit();
398 }
399
Adam Powell89e06452010-06-23 20:24:52 -0700400 /**
401 * @hide
402 */
Adam Powell5d279772010-07-27 16:34:07 -0700403 public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
Adam Powell6e346362010-07-23 10:18:23 -0700404 private ActionMode.Callback mCallback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700405 private MenuBuilder mMenu;
Adam Powell29ed7572010-07-14 16:24:56 -0700406 private WeakReference<View> mCustomView;
Adam Powell89e06452010-06-23 20:24:52 -0700407
Adam Powell5d279772010-07-27 16:34:07 -0700408 public ActionModeImpl(ActionMode.Callback callback) {
Adam Powell89e06452010-06-23 20:24:52 -0700409 mCallback = callback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700410 mMenu = new MenuBuilder(mActionView.getContext());
411 mMenu.setCallback(this);
Adam Powell89e06452010-06-23 20:24:52 -0700412 }
Adam Powell9168f0b2010-08-02 15:46:24 -0700413
414 @Override
415 public MenuInflater getMenuInflater() {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700416 return new MenuInflater(mContext);
Adam Powell9168f0b2010-08-02 15:46:24 -0700417 }
418
Adam Powell89e06452010-06-23 20:24:52 -0700419 @Override
420 public Menu getMenu() {
421 return mMenu;
422 }
423
424 @Override
425 public void finish() {
Adam Powell5d279772010-07-27 16:34:07 -0700426 if (mActionMode != this) {
427 // Not the active action mode - no-op
Adam Powell93b6bc32010-07-22 11:36:35 -0700428 return;
429 }
430
Adam Powell6e346362010-07-23 10:18:23 -0700431 mCallback.onDestroyActionMode(this);
Adam Powell89e06452010-06-23 20:24:52 -0700432 mAnimatorView.setDisplayedChild(NORMAL_VIEW);
Adam Powell0e94b512010-06-29 17:58:20 -0700433
434 // Clear out the context mode views after the animation finishes
Adam Powell3461b322010-07-14 11:34:43 -0700435 mClosingContext = true;
Adam Powell0e94b512010-06-29 17:58:20 -0700436 mHandler.postDelayed(mCloseContext, mAnimatorView.getOutAnimation().getDuration());
437
Adam Powell89e06452010-06-23 20:24:52 -0700438 if (mLowerContextView != null && mLowerContextView.getVisibility() != View.GONE) {
439 // TODO Animate this
440 mLowerContextView.setVisibility(View.GONE);
441 }
Adam Powell5d279772010-07-27 16:34:07 -0700442 mActionMode = null;
Adam Powell89e06452010-06-23 20:24:52 -0700443 }
444
445 @Override
446 public void invalidate() {
Adam Powell6e346362010-07-23 10:18:23 -0700447 if (mCallback.onPrepareActionMode(this, mMenu)) {
Adam Powell89e06452010-06-23 20:24:52 -0700448 // Refresh content in both context views
449 }
450 }
451
452 @Override
453 public void setCustomView(View view) {
454 mUpperContextView.setCustomView(view);
Adam Powell29ed7572010-07-14 16:24:56 -0700455 mCustomView = new WeakReference<View>(view);
Adam Powell89e06452010-06-23 20:24:52 -0700456 }
457
458 @Override
459 public void setSubtitle(CharSequence subtitle) {
460 mUpperContextView.setSubtitle(subtitle);
461 }
462
463 @Override
464 public void setTitle(CharSequence title) {
465 mUpperContextView.setTitle(title);
466 }
Adam Powell29ed7572010-07-14 16:24:56 -0700467
468 @Override
Adam Powellc9ae2a22010-07-28 14:44:21 -0700469 public void setTitle(int resId) {
470 setTitle(mActivity.getString(resId));
471 }
472
473 @Override
474 public void setSubtitle(int resId) {
475 setSubtitle(mActivity.getString(resId));
476 }
477
478 @Override
Adam Powell29ed7572010-07-14 16:24:56 -0700479 public CharSequence getTitle() {
480 return mUpperContextView.getTitle();
481 }
482
483 @Override
484 public CharSequence getSubtitle() {
485 return mUpperContextView.getSubtitle();
486 }
Adam Powell89e06452010-06-23 20:24:52 -0700487
Adam Powell29ed7572010-07-14 16:24:56 -0700488 @Override
489 public View getCustomView() {
490 return mCustomView != null ? mCustomView.get() : null;
491 }
492
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700493 public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
Adam Powell6e346362010-07-23 10:18:23 -0700494 return mCallback.onActionItemClicked(this, item);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700495 }
496
497 public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
498 }
499
500 public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
501 if (!subMenu.hasVisibleItems()) {
502 return true;
Adam Powell89e06452010-06-23 20:24:52 -0700503 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700504
Adam Powelldec9dfd2010-08-09 15:27:54 -0700505 new MenuPopupHelper(mContext, subMenu).show();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700506 return true;
507 }
508
509 public void onCloseSubMenu(SubMenuBuilder menu) {
510 }
511
512 public void onMenuModeChange(MenuBuilder menu) {
513 }
Adam Powell661c9082010-07-02 10:09:44 -0700514 }
515
516 /**
517 * @hide
518 */
519 public class TabImpl extends ActionBar.Tab {
520 private Fragment mFragment;
521 private Drawable mIcon;
522 private CharSequence mText;
523 private int mPosition;
524
525 @Override
526 public Fragment getFragment() {
527 return mFragment;
528 }
529
530 @Override
531 public Drawable getIcon() {
532 return mIcon;
533 }
534
535 @Override
536 public int getPosition() {
537 return mPosition;
538 }
539
540 public void setPosition(int position) {
541 mPosition = position;
542 }
543
544 @Override
545 public CharSequence getText() {
546 return mText;
547 }
548
549 @Override
550 public void setFragment(Fragment fragment) {
551 mFragment = fragment;
552 }
553
554 @Override
555 public void setIcon(Drawable icon) {
556 mIcon = icon;
557 }
558
559 @Override
560 public void setText(CharSequence text) {
561 mText = text;
562 }
563
564 @Override
565 public void select() {
566 selectTab(this);
Adam Powell89e06452010-06-23 20:24:52 -0700567 }
568 }
569}