Search in sources :

Example 1 with NavigationView

use of android.support.design.widget.NavigationView in project cheesesquare by chrisbanes.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with NavigationView

use of android.support.design.widget.NavigationView in project SeriesGuide by UweTrottmann.

the class BaseNavDrawerActivity method setupNavDrawer.

/**
     * Initializes the navigation drawer. Overriding activities should call this in their {@link
     * #onCreate(android.os.Bundle)} after {@link #setContentView(int)}.
     */
public void setupNavDrawer() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    actionBarToolbar = (Toolbar) drawerLayout.findViewById(R.id.sgToolbar);
    navigationView = (NavigationView) drawerLayout.findViewById(R.id.navigation);
    // setup nav drawer account header
    View headerView = navigationView.getHeaderView(0);
    ButterKnife.findById(headerView, R.id.containerDrawerAccountCloud).setOnClickListener(accountClickListener);
    ButterKnife.findById(headerView, R.id.containerDrawerAccountTrakt).setOnClickListener(accountClickListener);
    textViewHeaderUserCloud = ButterKnife.findById(headerView, R.id.textViewDrawerUserCloud);
    textViewHeaderUserTrakt = ButterKnife.findById(headerView, R.id.textViewDrawerUserTrakt);
    // setup nav drawer items
    navigationView.inflateMenu(R.menu.menu_drawer);
    navigationView.setItemIconTintList(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerIcon)));
    navigationView.setItemTextColor(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerText)));
    navigationView.setItemBackgroundResource(Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgActivatedItemBackgroundDrawer));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            onNavItemClick(menuItem.getItemId());
            return false;
        }
    });
    if (BuildConfig.DEBUG) {
        // add debug drawer
        View debugLayout = getLayoutInflater().inflate(R.layout.debug_drawer, drawerLayout, true);
        DebugView debugView = ButterKnife.findById(debugLayout, R.id.debugView);
        ButtonAction buttonClearTraktRefreshToken = new ButtonAction("Clear trakt refresh token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktOAuthSettings.storeRefreshData(getApplicationContext(), "", 3600);
            }
        });
        ButtonAction buttonInvalidateTraktAccessToken = new ButtonAction("Invalidate trakt access token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktCredentials.get(getApplicationContext()).storeAccessToken("invalid-token");
            }
        });
        ButtonAction buttonInvalidateTraktRefreshToken = new ButtonAction("Invalidate trakt refresh token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktOAuthSettings.storeRefreshData(getApplicationContext(), "invalid-token", 3600);
            }
        });
        debugView.modules(new ActionsModule(buttonClearTraktRefreshToken, buttonInvalidateTraktAccessToken, buttonInvalidateTraktRefreshToken), new TimberModule(), new DeviceModule(this));
    }
}
Also used : DeviceModule(io.palaima.debugdrawer.commons.DeviceModule) NavigationView(android.support.design.widget.NavigationView) ButtonAction(io.palaima.debugdrawer.actions.ButtonAction) MenuItem(android.view.MenuItem) DebugView(io.palaima.debugdrawer.view.DebugView) ActionsModule(io.palaima.debugdrawer.actions.ActionsModule) NavigationView(android.support.design.widget.NavigationView) DebugView(io.palaima.debugdrawer.view.DebugView) View(android.view.View) TextView(android.widget.TextView) TimberModule(io.palaima.debugdrawer.timber.TimberModule)

Example 3 with NavigationView

use of android.support.design.widget.NavigationView in project Fragmentation by YoKeyword.

the class MainActivity method initView.

private void initView() {
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    //        mDrawer.setDrawerListener(toggle);
    toggle.syncState();
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    mNavigationView.setCheckedItem(R.id.nav_home);
    LinearLayout llNavHeader = (LinearLayout) mNavigationView.getHeaderView(0);
    mTvName = (TextView) llNavHeader.findViewById(R.id.tv_name);
    mImgNav = (ImageView) llNavHeader.findViewById(R.id.img_nav);
    llNavHeader.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawer.closeDrawer(GravityCompat.START);
            mDrawer.postDelayed(new Runnable() {

                @Override
                public void run() {
                    goLogin();
                }
            }, 250);
        }
    });
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 4 with NavigationView

use of android.support.design.widget.NavigationView in project MaterialIntroView by iammert.

the class ToolbarMenuItemActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_toolbar);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //User toolbar to access the views
    ImageView ivSearch = (ImageView) toolbar.findViewById(R.id.ivToolbarSearch);
    mIvShare = (ImageView) toolbar.findViewById(R.id.ivToolbarShare);
    mIvAbout = (ImageView) toolbar.findViewById(R.id.ivToolbarAbout);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    //show the intro view
    showIntro(ivSearch, MENU_SEARCH_ID_TAG, getString(R.string.guide_setup_profile), FocusGravity.CENTER);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 5 with NavigationView

use of android.support.design.widget.NavigationView in project Timber by naman14.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    sMainActivity = this;
    action = getIntent().getAction();
    isDarkTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    navigationMap.put(Constants.NAVIGATE_LIBRARY, navigateLibrary);
    navigationMap.put(Constants.NAVIGATE_PLAYLIST, navigatePlaylist);
    navigationMap.put(Constants.NAVIGATE_QUEUE, navigateQueue);
    navigationMap.put(Constants.NAVIGATE_NOWPLAYING, navigateNowplaying);
    navigationMap.put(Constants.NAVIGATE_ALBUM, navigateAlbum);
    navigationMap.put(Constants.NAVIGATE_ARTIST, navigateArtist);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    panelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    View header = navigationView.inflateHeaderView(R.layout.nav_header);
    albumart = (ImageView) header.findViewById(R.id.album_art);
    songtitle = (TextView) header.findViewById(R.id.song_title);
    songartist = (TextView) header.findViewById(R.id.song_artist);
    setPanelSlideListeners(panelLayout);
    navDrawerRunnable.postDelayed(new Runnable() {

        @Override
        public void run() {
            setupDrawerContent(navigationView);
            setupNavigationIcons(navigationView);
        }
    }, 700);
    if (TimberUtils.isMarshmallow()) {
        checkPermissionAndThenLoad();
    } else {
        loadEverything();
    }
    addBackstackListener();
    if (Intent.ACTION_VIEW.equals(action)) {
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                MusicPlayer.clearQueue();
                MusicPlayer.openFile(getIntent().getData().getPath());
                MusicPlayer.playOrPause();
                navigateNowplaying.run();
            }
        }, 350);
    }
}
Also used : Handler(android.os.Handler) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

NavigationView (android.support.design.widget.NavigationView)59 View (android.view.View)36 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 Toolbar (android.support.v7.widget.Toolbar)21 TextView (android.widget.TextView)16 DrawerLayout (android.support.v4.widget.DrawerLayout)14 ImageView (android.widget.ImageView)14 UiController (android.support.test.espresso.UiController)12 ViewAction (android.support.test.espresso.ViewAction)12 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 Menu (android.view.Menu)7 Handler (android.os.Handler)6 ActionBar (android.support.v7.app.ActionBar)6 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)6 Intent (android.content.Intent)5 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 SearchView (android.support.v7.widget.SearchView)5 MenuItem (android.view.MenuItem)5 AdapterView (android.widget.AdapterView)5