Java Code Examples for android.app.ActionBar#OnNavigationListener

The following examples show how to use android.app.ActionBar#OnNavigationListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionBarCompat.java    From Ansole with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private ActionBar.OnNavigationListener wrapOnNavigationCallback(OnNavigationListener callback) {
       final OnNavigationListener cb = callback;
       return new ActionBar.OnNavigationListener() {
           @Override
		public boolean onNavigationItemSelected(int position, long id) {
               return cb.onNavigationItemSelected(position, id);
           }
       };
   }
 
Example 2
Source File: DrawerActivity.java    From UTubeTV with The Unlicense 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  // we set the activity to NoActionBar in the manifest to avoid the title flickering in the actionbar
  setTheme(R.style.DrawerActivityTheme);
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_drawer);

  mContent = Content.instance(this);

  if (mContent.needsChannelSwitcher()) {
    mActionBarSpinnerAdapter = new ActionBarSpinnerAdapter(this, mContent);
    ActionBar.OnNavigationListener listener = new ActionBar.OnNavigationListener() {
      @Override
      public boolean onNavigationItemSelected(int position, long itemId) {

        // be aware that this call back gets called when the spinner contents are built
        // we need to ignore that one, so not going to do anything if channel not changing
        if (!mSpinnerSucksBalls) {
          mSpinnerSucksBalls = true;

          // ## taking advantage of this feature/bug to set the real value of the actionbar spinner
          // if we don't do this, the spinner defaults to value 0, so selecting the first item
          // in the list will not work since it doesn't respond when selecting the same index as the current value
          getActionBar().setSelectedNavigationItem(mContent.currentChannelIndex());
        } else {
          if (mContent.changeChannel(position))
            updateSectionForChannel();
        }
        return true;
      }
    };

    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(mActionBarSpinnerAdapter, listener);
  }

  setupDrawer();

  // enable ActionBar app icon to behave as action to toggle nav drawer
  getActionBar().setDisplayHomeAsUpEnabled(true);

  selectSection(mContent.savedSectionIndex(), false);

  if (Constants.showAppRater) {
    AppRater.app_launched(this);
  }

  // general app tweaks
  //    Debug.activateStrictMode();
  Utils.ignoreObsoleteCapacitiveMenuButton(this);

  // show player if activity was destroyed and recreated
  if (savedInstanceState != null) {
    VideoPlayer.PlayerParams params = savedInstanceState.getParcelable("player_params");

    if (params != null)
      playVideo(params);
  }

  WhatsNewDialog.showWhatsNew(this, false);

  // only show intro for multi channels
  if (mContent.needsChannelSwitcher())
    IntroActivity.showIntroDelayed(this, false);
}