Пример #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) return true;

    if (android.R.id.home == item.getItemId()) {
      if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) mDrawerLayout.closeDrawers();
      else mDrawerLayout.openDrawer(GravityCompat.START);

      return true;
    }

    // 关于
    if (item.getItemId() == R.id.about) AboutWebFragment.launchAbout(this);
    // 意见反馈
    else if (item.getItemId() == R.id.feedback) PublishActivity.publishFeedback(this);
    // 好友分组
    else if (item.getItemId() == R.id.friendGroups) GroupSortFragment.lanuch(this);
    // 搜索用户或者微博
    //        else if (item.getItemId() == R.id.search)
    //            SearchActivity.launch(this);
    // 退出
    else if (item.getItemId() == R.id.exitapp) finish();
    // 新微博
    else if (item.getItemId() == R.id.publish) PublishActivity.publishStatus(this, null);
    // 搜人
    else if (item.getItemId() == R.id.search_user) SearchUserFragment.launch(this);
    // 搜微博
    else if (item.getItemId() == R.id.search_status) SearchTopicsFragment.launch(this);
    // 开始离线
    else if (item.getItemId() == R.id.toggle_offline) OfflineUtils.toggleOffline(this);

    return super.onOptionsItemSelected(item);
  }
Пример #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (drawerToggle != null && drawerToggle.onOptionsItemSelected(item)) return true;

    if (android.R.id.home == item.getItemId()) {
      if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) mDrawerLayout.closeDrawers();
      else mDrawerLayout.openDrawer(GravityCompat.START);

      return true;
    }

    // 关于
    //        if (item.getItemId() == R.id.about)
    //            AboutWebFragment.launchAbout(this);
    // 意见反馈
    //        else if (item.getItemId() == R.id.feedback)
    //            PublishActivity.publishFeedback(this);
    // 退出
    if (item.getItemId() == R.id.exitapp) {
      finish();

      MobclickAgent.onEvent(this, "exitapp");
    }
    // 新微博
    else if (item.getItemId() == R.id.publish) PublishActivity.publishStatus(this, null);
    // 开始离线
    else if (item.getItemId() == R.id.toggle_offline) {
      OfflineUtils.toggleOffline(this);

      MobclickAgent.onEvent(this, "toggle_offline");
    }
    // 停止离线
    else if (item.getItemId() == R.id.stop_offline) {
      OfflineService.stopOffline();

      MobclickAgent.onEvent(this, "stop_offline");
    }
    // 通知设置
    else if (item.getItemId() == R.id.notification_settings)
      NotificationSettingsFragment.launch(this);
    // 搜索
    else if (item.getItemId() == R.id.search) {
      new IAction(
          MainActivity.this,
          new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) {

        @Override
        public void doAction() {
          SearchFragment.launch(MainActivity.this, "");

          MobclickAgent.onEvent(MainActivity.this, "toggle_search");
        }
      }.run();
    }

    return super.onOptionsItemSelected(item);
  }