android.app.ActionBar#OnNavigationListener ( )源码实例Demo

下面列出了android.app.ActionBar#OnNavigationListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Ansole   文件: ActionBarCompat.java
@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);
           }
       };
   }
 
源代码2 项目: UTubeTV   文件: DrawerActivity.java
@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);
}