Search in sources :

Example 46 with NavigationView

use of android.support.design.widget.NavigationView in project material-components-android by material-components.

the class NavigationViewActions method removeHeaderView.

/** Removes a previously added header view from the navigation view. */
public static ViewAction removeHeaderView(@Nullable final View headerView) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayed();
        }

        @Override
        public String getDescription() {
            return "Remove header view";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            NavigationView navigationView = (NavigationView) view;
            navigationView.removeHeaderView(headerView);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : NavigationView(android.support.design.widget.NavigationView) ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) NavigationView(android.support.design.widget.NavigationView) View(android.view.View)

Example 47 with NavigationView

use of android.support.design.widget.NavigationView in project material-components-android by material-components.

the class NavigationViewActions method setItemTextColor.

/** Sets item text color on the content of the navigation view. */
public static ViewAction setItemTextColor(final ColorStateList textColor) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayed();
        }

        @Override
        public String getDescription() {
            return "Set item text color";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            NavigationView navigationView = (NavigationView) view;
            navigationView.setItemTextColor(textColor);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : NavigationView(android.support.design.widget.NavigationView) ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) NavigationView(android.support.design.widget.NavigationView) View(android.view.View)

Example 48 with NavigationView

use of android.support.design.widget.NavigationView in project BeautifulRefreshLayout by android-cjj.

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);
    ab.setTitle(null);
    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, "I'm CJJ", 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) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 49 with NavigationView

use of android.support.design.widget.NavigationView in project material-design-data by Luosunce.

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.mipmap.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.viewpage);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Snackbar.make(v, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Toast.makeText(MainActivity.this, "Toast comes out", Toast.LENGTH_SHORT).show();
                }
            }).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 50 with NavigationView

use of android.support.design.widget.NavigationView in project PocketHub by pockethub.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
    if (sp.getBoolean(PREF_FIRST_USE, true)) {
        openWelcomeScreen();
    }
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!userLearnedDrawer) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
                userLearnedDrawer = true;
                Log.d(TAG, "User learned drawer");
            }
        }
    };
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    getSupportLoaderManager().initLoader(0, null, this);
    TokenStore tokenStore = TokenStore.getInstance(this);
    if (tokenStore.getToken() == null) {
        AccountManager manager = AccountManager.get(this);
        Account[] accounts = manager.getAccountsByType(getString(R.string.account_type));
        if (accounts.length > 0) {
            Account account = accounts[0];
            AccountsHelper.getUserToken(this, account);
            tokenStore.saveToken(AccountsHelper.getUserToken(this, account));
        }
    }
}
Also used : Account(android.accounts.Account) SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) AccountManager(android.accounts.AccountManager) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TokenStore(com.meisolsson.githubsdk.core.TokenStore)

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