1 package com.android.ex.photo; 2 3 import android.app.ActionBar; 4 import android.graphics.drawable.Drawable; 5 6 /** 7 * Wrapper around {@link ActionBar}. 8 */ 9 public class ActionBarWrapper implements ActionBarInterface { 10 11 private final ActionBar mActionBar; 12 13 private class MenuVisiblityListenerWrapper implements ActionBar.OnMenuVisibilityListener { 14 15 private final ActionBarInterface.OnMenuVisibilityListener mWrapped; 16 MenuVisiblityListenerWrapper(ActionBarInterface.OnMenuVisibilityListener wrapped)17 public MenuVisiblityListenerWrapper(ActionBarInterface.OnMenuVisibilityListener wrapped) { 18 mWrapped = wrapped; 19 } 20 21 @Override onMenuVisibilityChanged(boolean isVisible)22 public void onMenuVisibilityChanged(boolean isVisible) { 23 mWrapped.onMenuVisibilityChanged(isVisible); 24 } 25 } 26 ActionBarWrapper(ActionBar actionBar)27 public ActionBarWrapper(ActionBar actionBar) { 28 mActionBar = actionBar; 29 } 30 31 @Override setDisplayHomeAsUpEnabled(boolean showHomeAsUp)32 public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { 33 mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp); 34 } 35 36 @Override addOnMenuVisibilityListener(OnMenuVisibilityListener listener)37 public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { 38 mActionBar.addOnMenuVisibilityListener(new MenuVisiblityListenerWrapper(listener)); 39 } 40 41 @Override setDisplayOptionsShowTitle()42 public void setDisplayOptionsShowTitle() { 43 mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); 44 } 45 46 @Override getTitle()47 public CharSequence getTitle() { 48 return mActionBar.getTitle(); 49 } 50 51 @Override setTitle(CharSequence title)52 public void setTitle(CharSequence title) { 53 mActionBar.setTitle(title); 54 } 55 56 @Override setSubtitle(CharSequence subtitle)57 public void setSubtitle(CharSequence subtitle) { 58 mActionBar.setSubtitle(subtitle); 59 } 60 61 @Override show()62 public void show() { 63 mActionBar.show(); 64 } 65 66 @Override hide()67 public void hide() { 68 mActionBar.hide(); 69 } 70 71 @Override setLogo(Drawable logo)72 public void setLogo(Drawable logo) { 73 mActionBar.setLogo(logo); 74 } 75 76 } 77