Search in sources :

Example 1 with RootProjectsActivity

use of com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity in project TeamCityApp by vase4kin.

the class DrawerViewImpl method initDrawer.

/**
 * Init drawer
 */
private void initDrawer() {
    BadgeStyle badgeStyle = new BadgeStyle().withTextColor(Color.WHITE).withColorRes(mDefaultColor);
    mDrawerResult = new DrawerBuilder().withActivity(mActivity).withToolbar(mToolbar).withAccountHeader(mHeaderResult).addDrawerItems(new PrimaryDrawerItem().withName(R.string.projects_drawer_item).withIcon(new IconDrawable(mActivity, MaterialIcons.md_home).colorRes(mDefaultColor)).withSelectedTextColorRes(mDefaultColor).withIdentifier(PROJECTS), new PrimaryDrawerItem().withName(R.string.running_builds_drawer_item).withIcon(new IconDrawable(mActivity, MaterialIcons.md_directions_run).colorRes(mDefaultColor)).withSelectedTextColorRes(mDefaultColor).withBadgeStyle(badgeStyle).withIdentifier(RUNNING_BUILDS), new PrimaryDrawerItem().withName(R.string.build_queue_drawer_item).withIcon(new IconDrawable(mActivity, MaterialIcons.md_layers).colorRes(mDefaultColor)).withSelectedTextColorRes(mDefaultColor).withBadgeStyle(badgeStyle).withIdentifier(BUILD_QUEUE), new PrimaryDrawerItem().withName(R.string.agents_drawer_item).withIcon(new IconDrawable(mActivity, MaterialIcons.md_directions_railway).colorRes(mDefaultColor)).withSelectedTextColorRes(mDefaultColor).withBadgeStyle(badgeStyle).withIdentifier(AGENTS), new DividerDrawerItem(), new PrimaryDrawerItem().withName("About").withIcon(new IconDrawable(mActivity, MaterialIcons.md_help).colorRes(mDefaultColor)).withSelectedTextColorRes(mDefaultColor).withIdentifier(ABOUT)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (drawerItem != null) {
                switch((int) drawerItem.getIdentifier()) {
                    case PROJECTS:
                        if (mActivity instanceof RootProjectsActivity) {
                            break;
                        }
                        mOnDrawerPresenterListener.startRootProjectsActivity();
                        break;
                    case AGENTS:
                        if (mActivity instanceof AgentTabsActivity) {
                            break;
                        }
                        mOnDrawerPresenterListener.startAgentActivity();
                        break;
                    case RUNNING_BUILDS:
                        if (mActivity instanceof RunningBuildsListActivity) {
                            break;
                        }
                        mOnDrawerPresenterListener.startBuildRunningActivity();
                        break;
                    case BUILD_QUEUE:
                        if (mActivity instanceof BuildQueueActivity) {
                            break;
                        }
                        mOnDrawerPresenterListener.startQueuedBuildsActivity();
                        break;
                    case ABOUT:
                        if (mActivity instanceof AboutLibrariesActivity) {
                            break;
                        }
                        mOnDrawerPresenterListener.startAboutActivity();
                        break;
                    default:
                        showDialogWithAdvice();
                        break;
                }
            }
            return false;
        }
    }).withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {

        @Override
        public boolean onNavigationClickListener(View clickedView) {
            // this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
            // if the back arrow is shown. close the activity
            backButtonPressed();
            // return true if we have consumed the event
            return true;
        }
    }).withOnDrawerListener(new OnDrawerListenerImpl(mOnDrawerPresenterListener)).withShowDrawerOnFirstLaunch(false).build();
}
Also used : PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) DividerDrawerItem(com.mikepenz.materialdrawer.model.DividerDrawerItem) AboutLibrariesActivity(com.github.vase4kin.teamcityapp.about.AboutLibrariesActivity) Drawer(com.mikepenz.materialdrawer.Drawer) View(android.view.View) RunningBuildsListActivity(com.github.vase4kin.teamcityapp.runningbuilds.view.RunningBuildsListActivity) BuildQueueActivity(com.github.vase4kin.teamcityapp.queue.view.BuildQueueActivity) RootProjectsActivity(com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity) AgentTabsActivity(com.github.vase4kin.teamcityapp.agenttabs.view.AgentTabsActivity) BadgeStyle(com.mikepenz.materialdrawer.holder.BadgeStyle) IconDrawable(com.joanzapata.iconify.IconDrawable) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder)

Aggregations

View (android.view.View)1 AboutLibrariesActivity (com.github.vase4kin.teamcityapp.about.AboutLibrariesActivity)1 AgentTabsActivity (com.github.vase4kin.teamcityapp.agenttabs.view.AgentTabsActivity)1 BuildQueueActivity (com.github.vase4kin.teamcityapp.queue.view.BuildQueueActivity)1 RootProjectsActivity (com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity)1 RunningBuildsListActivity (com.github.vase4kin.teamcityapp.runningbuilds.view.RunningBuildsListActivity)1 IconDrawable (com.joanzapata.iconify.IconDrawable)1 Drawer (com.mikepenz.materialdrawer.Drawer)1 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)1 BadgeStyle (com.mikepenz.materialdrawer.holder.BadgeStyle)1 DividerDrawerItem (com.mikepenz.materialdrawer.model.DividerDrawerItem)1 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)1 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)1