Search in sources :

Example 26 with NavigationView

use of android.support.design.widget.NavigationView in project SuperToasts by JohnPersano.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            // Stop animating the navigation icon
            super.onDrawerSlide(drawerView, 0);
        }
    };
    drawerLayout.addDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();
    final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.navigation_drawer_supertoast);
    // setCheckedItem() does not actually call the associated listener
    if (savedInstanceState == null)
        this.onNavigationItemSelected(navigationView.getMenu().getItem(0));
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 27 with NavigationView

use of android.support.design.widget.NavigationView in project XposedInstaller by rovo89.

the class WelcomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ThemeUtil.setTheme(this);
    setContentView(R.layout.activity_welcome);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
    assert mNavigationView != null;
    mNavigationView.setNavigationItemSelectedListener(this);
    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // this disables the arrow @ completed state
            super.onDrawerSlide(drawerView, 0);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            // this disables the animation
            super.onDrawerSlide(drawerView, 0);
        }
    };
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mSelectedId = mNavigationView.getMenu().getItem(prefs.getInt("default_view", 0)).getItemId();
    mSelectedId = savedInstanceState == null ? mSelectedId : savedInstanceState.getInt(SELECTED_ITEM_ID);
    mPrevSelectedId = mSelectedId;
    mNavigationView.getMenu().findItem(mSelectedId).setChecked(true);
    if (savedInstanceState == null) {
        mDrawerHandler.removeCallbacksAndMessages(null);
        mDrawerHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                navigate(mSelectedId);
            }
        }, 250);
        boolean openDrawer = prefs.getBoolean("open_drawer", false);
        if (openDrawer)
            mDrawerLayout.openDrawer(GravityCompat.START);
        else
            mDrawerLayout.closeDrawers();
    }
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        int value = extras.getInt("fragment", prefs.getInt("default_view", 0));
        switchFragment(value);
    }
    mRepoLoader = RepoLoader.getInstance();
    ModuleUtil.getInstance().addListener(this);
    mRepoLoader.addListener(this);
    notifyDataSetChanged();
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 28 with NavigationView

use of android.support.design.widget.NavigationView in project chefly_android by chef-ly.

the class RecipeListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recipe_list);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    //Initialize recipe lists
    serverRecipes = new RecipeList();
    favoriteRecipes = new RecipeList();
    //Start AsyncTaskLoader to get FavoriteRecipes
    Credentials cred = CredentialsManager.getCredentials(getApplicationContext());
    String t = cred.getAccessToken();
    Log.d(TAG, "Token -> " + t);
    if (t != null) {
        RequestMethod requestPackageFavs = new RequestMethod();
        requestPackageFavs.setEndPoint(urlFavsString);
        requestPackageFavs.setMethod("GET");
        requestPackageFavs.setHeader("Authorization", "Bearer " + t);
        Bundle bundlefavs = new Bundle();
        bundlefavs.putParcelable("requestPackage", requestPackageFavs);
        getSupportLoaderManager().initLoader(FAVORTIESID, bundlefavs, this).forceLoad();
    } else {
        Toast.makeText(this, "Could not retrieve favorites, token is null", Toast.LENGTH_SHORT).show();
    }
    // PageViewer
    pager = (ViewPager) findViewById(R.id.viewpager);
    Bundle serv = new Bundle();
    serv.putString("title", "Recipes");
    serv.putString("pageNum", "1");
    serv.putString("search", "");
    server = new ListViewFragment();
    server.setArguments(serv);
    Bundle f = new Bundle();
    f.putString("title", "Favorites");
    f.putString("pageNum", "2");
    f.putString("search", "");
    favs = new ListViewFragment();
    favs.setArguments(f);
    ListViewFragment[] frags = { server, favs };
    pager.setAdapter(new RecipeListPagerAdapter(getSupportFragmentManager(), frags));
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            //Log.d(TAG, "Position -> " + position);
            if (position == 1) {
                favoritesHeader.setPaintFlags(favoritesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
                recipesHeader.setPaintFlags(0);
            // ingredientsHeader.setPaintFlags(0);
            } else {
                recipesHeader.setPaintFlags(recipesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
                favoritesHeader.setPaintFlags(0);
            // ingredientsHeader.setPaintFlags(0);
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    // Header links
    // ingredientsHeader = (TextView) findViewById(R.id.ingredientsHeader);
    favoritesHeader = (TextView) findViewById(R.id.favortiesHeader);
    recipesHeader = (TextView) findViewById(R.id.recipesHeader);
    View.OnClickListener headerListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (v.getId() == favoritesHeader.getId()) {
                favoritesHeader.setPaintFlags(favoritesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
                recipesHeader.setPaintFlags(0);
                //  ingredientsHeader.setPaintFlags(0);
                pager.setCurrentItem(1);
            } else {
                recipesHeader.setPaintFlags(recipesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
                favoritesHeader.setPaintFlags(0);
                //  ingredientsHeader.setPaintFlags(0);
                pager.setCurrentItem(0);
            }
        }
    };
    // ingredientsHeader.setOnClickListener(headerListener);
    favoritesHeader.setOnClickListener(headerListener);
    recipesHeader.setOnClickListener(headerListener);
    //Tool/Appbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Navigation Drawer
    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.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) RequestMethod(com.se491.chef_ly.http.RequestMethod) Bundle(android.os.Bundle) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint) RecipeList(com.se491.chef_ly.model.RecipeList) DrawerLayout(android.support.v4.widget.DrawerLayout) Credentials(com.auth0.android.result.Credentials) Toolbar(android.support.v7.widget.Toolbar)

Example 29 with NavigationView

use of android.support.design.widget.NavigationView in project dobby-android by InceptAi.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ((DobbyApplication) getApplication()).getProdComponent().inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    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);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        drawer.addDrawerListener(toggle);
    } else {
        drawer.setDrawerListener(toggle);
    }
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    dobbyAi.setResponseCallback(this);
    handler = new Handler(this);
    setupChatFragment();
//requestPermissions();
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Handler(android.os.Handler) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 30 with NavigationView

use of android.support.design.widget.NavigationView in project Varis-Android by dkhmelenko.

the class MainActivity method setupDrawerLayout.

/**
     * Sets up navigation drawer layout
     */
private void setupDrawerLayout() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    final NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            switch(menuItem.getItemId()) {
                case R.id.drawer_login:
                    Intent loginIntent = new Intent(MainActivity.this, AuthActivity.class);
                    startActivityForResult(loginIntent, AUTH_ACTIVITY_CODE);
                    break;
                case R.id.drawer_logout:
                    getPresenter().userLogout();
                    finish();
                    startActivity(getIntent());
                    break;
                case R.id.drawer_licenses:
                    LicensesDialogFragment dialog = LicensesDialogFragment.newInstance();
                    dialog.show(getSupportFragmentManager(), "LicensesDialog");
                    break;
                case R.id.drawer_about:
                    Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class);
                    startActivity(aboutIntent);
                    break;
            }
            menuItem.setChecked(false);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}
Also used : LicensesDialogFragment(com.khmelenko.lab.varis.fragment.LicensesDialogFragment) NavigationView(android.support.design.widget.NavigationView) MenuItem(android.view.MenuItem) Intent(android.content.Intent)

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