Search in sources :

Example 16 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 17 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 18 with NavigationView

use of android.support.design.widget.NavigationView in project FlowingDrawer by mxn21.

the class MenuListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_menu, container, false);
    ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);
    NavigationView vNavigation = (NavigationView) view.findViewById(R.id.vNavigation);
    vNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Toast.makeText(getActivity(), menuItem.getTitle(), Toast.LENGTH_SHORT).show();
            return false;
        }
    });
    setupHeader();
    return view;
}
Also used : NavigationView(android.support.design.widget.NavigationView) MenuItem(android.view.MenuItem) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View)

Example 19 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)

Example 20 with NavigationView

use of android.support.design.widget.NavigationView in project NoteText by ViWu.

the class MainActivity method setUpDrawer.

public void setUpDrawer(Toolbar toolbar) {
    //set up drawer
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer != null) {
        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);
    assert navigationView != null;
    navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout)

Aggregations

NavigationView (android.support.design.widget.NavigationView)70 View (android.view.View)42 Toolbar (android.support.v7.widget.Toolbar)25 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)24 TextView (android.widget.TextView)21 DrawerLayout (android.support.v4.widget.DrawerLayout)17 ImageView (android.widget.ImageView)16 UiController (android.support.test.espresso.UiController)13 ViewAction (android.support.test.espresso.ViewAction)13 Menu (android.view.Menu)10 ActionBar (android.support.v7.app.ActionBar)8 Intent (android.content.Intent)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 SearchView (android.support.v7.widget.SearchView)6 BindView (butterknife.BindView)6 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)6 TabLayout (android.support.design.widget.TabLayout)5 FlakyTest (android.support.test.filters.FlakyTest)5