public boolean onMenuSelected(MenuBean menu, boolean replace, View view) { if (!replace && lastSelectedMenu != null && lastSelectedMenu.getType().equals(menu.getType())) { closeDrawer(); return true; } int type = Integer.parseInt(menu.getType()); ABaseFragment fragment = null; if (mStripView != null) mStripView.clearAnimation(); mStripView = null; if (animatorSet != null) { animatorSet.removeAllListeners(); animatorSet.end(); animatorSet = null; } mToolbar.setTranslationY(0); switch (type) { // 微博首页 case 1: fragment = TimelineTabsFragment.newInstance(); break; // 提及 case 2: fragment = MentionTabsFragment.newInstance(); break; // 评论 case 3: fragment = CommentTabsFragment.newInstance(); break; // 朋友关系 case 4: fragment = FriendshipTabsFragment.newInstance(); break; // 设置 case 5: closeDrawer(); SettingsPagerFragment.launch(this); return true; // 草稿箱 case 6: fragment = DraftFragment.newInstance(); break; // 私信 case 10: new DMAction(this).run(); return true; // 热门微博 case 11: WeiboClientActivity.launchHotStatuses(this); closeDrawer(); return true; } if (fragment == null) return true; getSupportActionBar().setSubtitle(null); getSupportActionBar().setTitle(menu.getTitleRes()); FragmentTransaction ft = getFragmentManager().beginTransaction(); // ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, // android.R.animator.fade_in, android.R.animator.fade_out); ft.replace(R.id.content_frame, fragment, FRAGMENT_TAG).commit(); lastSelectedMenu = menu; menuFragment.setSelectedMenu(menu); setFabType(); return false; }
/** * 选择了侧边栏,切换侧边栏菜单 * * @param item * @return */ @Override public void onMenuClicked(MenuFragment.NavMenuItem item, boolean closeDrawer) { invalidateOptionsMenu(); ABaseFragment fragment = null; // 切换ContentFragment,或者跳转到新的界面 switch (item.id) { // 首页 case MenuFragment.MENU_MAIN: fabGroupsFragment.triggerLastPosition(); break; // 通知 case MenuFragment.MENU_NOTIFICATION: fragment = NotificationPagerFragment.newInstance(newIntentNotificationIndex); newIntentNotificationIndex = -1; break; // 提及 case MenuFragment.MENU_MENTION: fragment = MentionPagerFragment.newInstance(); break; // 评论 case MenuFragment.MENU_CMT: fragment = CommentPagerFragment.newInstance(); break; // 私信 case MenuFragment.MENU_MD: new IAction( MainActivity.this, new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) { @Override public void doAction() { WeiboClientActivity.launchDM(MainActivity.this); } }.run(); MobclickAgent.onEvent(MainActivity.this, "md"); break; // 热门微博 case MenuFragment.MENU_HOT_STATUS: WeiboClientActivity.launchHotStatuses(this); MobclickAgent.onEvent(MainActivity.this, "hot_status"); break; // 草稿箱 case MenuFragment.MENU_DRAT: fragment = DraftFragment.newInstance(); break; // 设置 case MenuFragment.MENU_SETTINGS: SettingsPagerFragment.launch(this); break; // 轻松一刻 case MenuFragment.MENU_JOKE: fragment = JokesPagerFragment.newInstance(); MobclickAgent.onEvent(this, "menu_joke"); break; // 精美壁纸 case MenuFragment.MENU_WALLPAPER: fragment = WallpaperFragment.newInstance(); MobclickAgent.onEvent(this, "menu_wallpaper"); break; } if (fragment != null) { setFragemnt(fragment, getString(item.toolbarRes)); } // 隐藏Fab按钮 if (item.id == 1) { fabBtn.setVisibility(View.VISIBLE); // 显示Fab BizFragment.createBizFragment(this).getFabAnimator().show(); } else { fabBtn.setVisibility(View.GONE); } // 关闭侧边栏 if (closeDrawer) { mHandler.postDelayed( new Runnable() { @Override public void run() { closeDrawer(); } }, 300); } }