Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.actionbarsherlock.internal.app;
  
  import java.util.HashSet;
  import java.util.Set;
  
 
 
     private final Activity mActivity;
     private final android.app.ActionBar mActionBar;
 
 
     public ActionBarWrapper(Activity activity) {
          = activity;
          = activity.getActionBar();
         if ( != null) {
             .addOnMenuVisibilityListener(this);
         }
     }
 
 
     @Override
     public void setHomeButtonEnabled(boolean enabled) {
         .setHomeButtonEnabled(enabled);
     }
 
     @Override
     public Context getThemedContext() {
         return .getThemedContext();
     }
 
     @Override
     public void setCustomView(View view) {
         .setCustomView(view);
     }
 
     @Override
     public void setCustomView(View viewLayoutParams layoutParams) {
         android.app.ActionBar.LayoutParams lp = new android.app.ActionBar.LayoutParams(layoutParams);
         lp.gravity = layoutParams.gravity;
         lp.bottomMargin = layoutParams.bottomMargin;
         lp.topMargin = layoutParams.topMargin;
         lp.leftMargin = layoutParams.leftMargin;
         lp.rightMargin = layoutParams.rightMargin;
         .setCustomView(viewlp);
     }
 
     @Override
     public void setCustomView(int resId) {
         .setCustomView(resId);
     }
 
     @Override
     public void setIcon(int resId) {
         .setIcon(resId);
     }
 
     @Override
     public void setIcon(Drawable icon) {
         .setIcon(icon);
     }
 
     @Override
     public void setLogo(int resId) {
         .setLogo(resId);
     }
 
     @Override
     public void setLogo(Drawable logo) {
         .setLogo(logo);
     }
 
     @Override
     public void setListNavigationCallbacks(SpinnerAdapter adapterOnNavigationListener callback) {
          = callback;
         .setListNavigationCallbacks(adapter, (callback != null) ? this : null);
     }
 
     @Override
     public boolean onNavigationItemSelected(int itemPositionlong itemId) {
         //This should never be a NullPointerException since we only set
         //ourselves as the listener when the callback is not null.
         return .onNavigationItemSelected(itemPositionitemId);
     }
 
     @Override
     public void setSelectedNavigationItem(int position) {
         .setSelectedNavigationItem(position);
    }
    @Override
    public int getSelectedNavigationIndex() {
        return .getSelectedNavigationIndex();
    }
    @Override
    public int getNavigationItemCount() {
        return .getNavigationItemCount();
    }
    @Override
    public void setTitle(CharSequence title) {
        .setTitle(title);
    }
    @Override
    public void setTitle(int resId) {
        .setTitle(resId);
    }
    @Override
    public void setSubtitle(CharSequence subtitle) {
        .setSubtitle(subtitle);
    }
    @Override
    public void setSubtitle(int resId) {
        .setSubtitle(resId);
    }
    @Override
    public void setDisplayOptions(int options) {
        .setDisplayOptions(options);
    }
    @Override
    public void setDisplayOptions(int optionsint mask) {
        .setDisplayOptions(optionsmask);
    }
    @Override
    public void setDisplayUseLogoEnabled(boolean useLogo) {
        .setDisplayUseLogoEnabled(useLogo);
    }
    @Override
    public void setDisplayShowHomeEnabled(boolean showHome) {
        .setDisplayShowHomeEnabled(showHome);
    }
    @Override
    public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
        .setDisplayHomeAsUpEnabled(showHomeAsUp);
    }
    @Override
    public void setDisplayShowTitleEnabled(boolean showTitle) {
        .setDisplayShowTitleEnabled(showTitle);
    }
    @Override
    public void setDisplayShowCustomEnabled(boolean showCustom) {
        .setDisplayShowCustomEnabled(showCustom);
    }
    @Override
    public void setBackgroundDrawable(Drawable d) {
    }
    @Override
    public void setStackedBackgroundDrawable(Drawable d) {
    }
    @Override
    public void setSplitBackgroundDrawable(Drawable d) {
    }
    @Override
    public View getCustomView() {
        return .getCustomView();
    }
    @Override
    public CharSequence getTitle() {
        return .getTitle();
    }
    @Override
    public CharSequence getSubtitle() {
        return .getSubtitle();
    }
    @Override
    public int getNavigationMode() {
        return .getNavigationMode();
    }
    @Override
    public void setNavigationMode(int mode) {
        .setNavigationMode(mode);
    }
    @Override
    public int getDisplayOptions() {
        return .getDisplayOptions();
    }
    public class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener {
        final android.app.ActionBar.Tab mNativeTab;
        private Object mTag;
        private TabListener mListener;
        public TabWrapper(android.app.ActionBar.Tab nativeTab) {
             = nativeTab;
            .setTag(this);
        }
        @Override
        public int getPosition() {
            return .getPosition();
        }
        @Override
        public Drawable getIcon() {
            return .getIcon();
        }
        @Override
        public CharSequence getText() {
            return .getText();
        }
        @Override
        public Tab setIcon(Drawable icon) {
            .setIcon(icon);
            return this;
        }
        @Override
        public Tab setIcon(int resId) {
            .setIcon(resId);
            return this;
        }
        @Override
        public Tab setText(CharSequence text) {
            .setText(text);
            return this;
        }
        @Override
        public Tab setText(int resId) {
            .setText(resId);
            return this;
        }
        @Override
        public Tab setCustomView(View view) {
            .setCustomView(view);
            return this;
        }
        @Override
        public Tab setCustomView(int layoutResId) {
            .setCustomView(layoutResId);
            return this;
        }
        @Override
        public View getCustomView() {
            return .getCustomView();
        }
        @Override
        public Tab setTag(Object obj) {
             = obj;
            return this;
        }
        @Override
        public Object getTag() {
            return ;
        }
        @Override
        public Tab setTabListener(TabListener listener) {
            .setTabListener(listener != null ? this : null);
             = listener;
            return this;
        }
        @Override
        public void select() {
            .select();
        }
        @Override
        public Tab setContentDescription(int resId) {
            .setContentDescription(resId);
            return this;
        }
        @Override
        public Tab setContentDescription(CharSequence contentDesc) {
            .setContentDescription(contentDesc);
            return this;
        }
        @Override
        public CharSequence getContentDescription() {
            return .getContentDescription();
        }
        @Override
        public void onTabReselected(android.app.ActionBar.Tab tabandroid.app.FragmentTransaction ft) {
            if ( != null) {
                FragmentTransaction trans = null;
                if ( instanceof FragmentActivity) {
                    trans = ((FragmentActivity)).getSupportFragmentManager().beginTransaction()
                            .disallowAddToBackStack();
                }
                .onTabReselected(thistrans);
                if (trans != null && !trans.isEmpty()) {
                    trans.commit();
                }
            }
        }
        @Override
        public void onTabSelected(android.app.ActionBar.Tab tabandroid.app.FragmentTransaction ft) {
            if ( != null) {
                if ( == null &&  instanceof FragmentActivity) {
                            .disallowAddToBackStack();
                }
                .onTabSelected(this);
                if ( != null) {
                    if (!.isEmpty()) {
                        .commit();
                    }
                     = null;
                }
            }
        }
        @Override
        public void onTabUnselected(android.app.ActionBar.Tab tabandroid.app.FragmentTransaction ft) {
            if ( != null) {
                FragmentTransaction trans = null;
                if ( instanceof FragmentActivity) {
                    trans = ((FragmentActivity)).getSupportFragmentManager().beginTransaction()
                            .disallowAddToBackStack();
                     = trans;
                }
                .onTabUnselected(thistrans);
            }
        }
    }
    @Override
    public Tab newTab() {
        return new TabWrapper(.newTab());
    }
    @Override
    public void addTab(Tab tab) {
        .addTab(((TabWrapper)tab).);
    }
    @Override
    public void addTab(Tab tabboolean setSelected) {
        .addTab(((TabWrapper)tab).setSelected);
    }
    @Override
    public void addTab(Tab tabint position) {
        .addTab(((TabWrapper)tab).position);
    }
    @Override
    public void addTab(Tab tabint positionboolean setSelected) {
        .addTab(((TabWrapper)tab).positionsetSelected);
    }
    @Override
    public void removeTab(Tab tab) {
        .removeTab(((TabWrapper)tab).);
    }
    @Override
    public void removeTabAt(int position) {
        .removeTabAt(position);
    }
    @Override
    public void removeAllTabs() {
        .removeAllTabs();
    }
    @Override
    public void selectTab(Tab tab) {
        .selectTab(((TabWrapper)tab).);
    }
    @Override
    public Tab getSelectedTab() {
        android.app.ActionBar.Tab selected = .getSelectedTab();
        return (selected != null) ? (Tab)selected.getTag() : null;
    }
    @Override
    public Tab getTabAt(int index) {
        android.app.ActionBar.Tab selected = .getTabAt(index);
        return (selected != null) ? (Tab)selected.getTag() : null;
    }
    @Override
    public int getTabCount() {
        return .getTabCount();
    }
    @Override
    public int getHeight() {
        return .getHeight();
    }
    @Override
    public void show() {
        .show();
    }
    @Override
    public void hide() {
        .hide();
    }
    @Override
    public boolean isShowing() {
        return .isShowing();
    }
    @Override
    public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
        .add(listener);
    }
    @Override
        .remove(listener);
    }
    @Override
    public void onMenuVisibilityChanged(boolean isVisible) {
        for (OnMenuVisibilityListener listener : ) {
            listener.onMenuVisibilityChanged(isVisible);
        }
    }
New to GrepCode? Check out our FAQ X