@Override public void onClick(View v) { navDrawer.setOpen(false); if (this.navDrawer.activity.getClass() == targetActivity) return; super.onClick(v); final BaseActivity activity = navDrawer.activity; activity.fadeOut( new BaseActivity.FadeOutListener() { @Override public void onFadeOutEnd() { activity.startActivity(new Intent(activity, targetActivity)); activity.finish(); } }); }
public NavDrawer(BaseActivity activity) { this.activity = activity; items = new ArrayList<>(); drawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); navDrawerView = (ViewGroup) activity.findViewById(R.id.nav_drawer); if (drawerLayout == null && navDrawerView == null) { throw new RuntimeException( "To use this class, you must have views with the ids of drawer_layout and nav_drawer"); } Toolbar toolbar = activity.getToolbar(); toolbar.setNavigationIcon(R.drawable.ic_action_navigation_menu); toolbar.setNavigationOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setOpen(!isOpen()); } }); activity.getYoraApplication().getBus().register(this); }
public void destroy() { activity.getYoraApplication().getBus().unregister(this); }
public void create() { LayoutInflater layoutInflater = activity.getLayoutInflater(); for (NavDrawerItem item : items) { item.inflate(layoutInflater, navDrawerView); } }