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