Java Code Examples for android.support.v7.app.ActionBarDrawerToggle.syncState()

The following are Jave code examples for showing how to use syncState() of the android.support.v7.app.ActionBarDrawerToggle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Mix   File: MainActivity.java   Source Code and License Vote up 12 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flex_box_layout);
    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 (drawer != null) {
        drawer.addDrawerListener(toggle);
    }
    toggle.syncState();

    initNavigation();
    initListener();
}
 
Example 2
Project: AndroidApp-Deploy   File: MainActivity.java   Source Code and License Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Well done Paolo! Thanks too Dom and Mihchele", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    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);
}
 
Example 3
Project: DroidSentinel   File: MainActivity.java   Source Code and License Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    consola = (TextView) findViewById(R.id.log);
    log = "";
    ok = false;

    et1 = (EditText)findViewById(R.id.threshold);
    et2 = (EditText)findViewById(R.id.window_len);
    et3 = (EditText)findViewById(R.id.maxts);
    et4 = (EditText)findViewById(R.id.readyforescast);

    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);
}
 
Example 4
Project: Hello-KUET   File: MainActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    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);

}
 
Example 5
Project: Hands-On-Android-UI-Development   File: NavigationMenuActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_menu);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );

    drawer.addDrawerListener(toggle);
    toggle.syncState();
    drawer.openDrawer(Gravity.START);
}
 
Example 6
Project: GlossikaSchedule   File: MainActivity.java   Source Code and License Vote up 6 votes
private void setupNavigationDrawer() {
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	getSupportActionBar().setHomeButtonEnabled(true);
	drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) {
		public void onDrawerClosed(View view) {
			super.onDrawerClosed(view);
			invalidateOptionsMenu();
		}

		public void onDrawerOpened(View drawerView) {
			super.onDrawerOpened(drawerView);
			invalidateOptionsMenu();
		}
	};
	drawerToggle.syncState();
	drawerToggle.setDrawerIndicatorEnabled(true);
	drawerLayout.setDrawerListener(drawerToggle);
	RecyclerView recyclerView = (RecyclerView) findViewById(R.id.navigationRecyclerView);
	navigationAdapter = new NavigationAdapter(this, schedules, schedules.indexOf(loadedSchedule));
	recyclerView.setAdapter(navigationAdapter);
	RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
	recyclerView.setLayoutManager(layoutManager);
}
 
Example 7
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: Reportes.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reportes_navigation_drawer);
    this.setTitle(R.string.nav_reportes);

    /*menu*/
    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_reportes);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.reportes_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.reportes_nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_reportes);
}
 
Example 8
Project: GitHub   File: MainActivity.java   Source Code and License Vote up 6 votes
private void initViews() {

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        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) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

    }
 
Example 9
Project: Hillffair17   File: HomescreenNew.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    initCollapsingToolbar();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, 0, 0);
    actionBarDrawerToggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    pref = new SharedPref(this);

    if(new Connection(this).isInternet()){
        profileBasicInfo(pref.getUserId());
    }

}
 
Example 10
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: Inicio.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inicio_navigation_drawer);
    this.setTitle(R.string.nav_inicio);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_inicio);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.inicio_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.inicio_nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_inicio);

}
 
Example 11
Project: civify-app   File: DrawerActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(getResources().getString(R.string.navigate_title));
    setSupportActionBar(mToolbar);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.bar_layout);
    mShowMenu = false;

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    mFragmentStack = new Stack<>();

    NavigateFragment navigateFragment = NavigateFragment.newInstance();
    setFragment(navigateFragment, NAVIGATE_ID);
    mNavigationView.getMenu().getItem(mCurrentFragmentId).setChecked(true);

    setUserHeader();
    AdapterFactory.getInstance().getUserAdapter(this).addOnCurrentUserUpdateListener(
            new Runnable() {
            @Override
            public void run() {
                Log.d("DrawerActivityListener", "CURRENT USER UPDATE LISTENER");
                setUserHeader();
            }
        }
    );

    checkNewAchievementsEvents();
}
 
Example 12
Project: GitHub   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  unbinder = ButterKnife.bind(this);
  toolbar.setTitle("Mosby MVI");
  toolbar.inflateMenu(R.menu.activity_main_toolbar);
  toolbar.setOnMenuItemClickListener(item -> {

    getSupportFragmentManager().beginTransaction()
        .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
            android.R.anim.fade_in, android.R.anim.fade_out)
        .add(R.id.drawerLayout, new SearchFragment())
        .addToBackStack("Search")
        .commit();
    return true;
  });

  ActionBarDrawerToggle toggle =
      new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open,
          R.string.navigation_drawer_close);
  drawer.addDrawerListener(toggle);
  toggle.syncState();

  if (savedInstanceState == null) {
    showCategoryItems(MainMenuItem.HOME);
  } else {
    title = savedInstanceState.getString(KEY_TOOLBAR_TITLE);
    toolbar.setTitle(title);
  }

  // TODO Create a Presenter & ViewState for this Activity
  DependencyInjection dependencyInjection = SampleApplication.getDependencyInjection(this);
  disposable = dependencyInjection.getMainMenuPresenter()
      .getViewStateObservable()
      .filter(state -> state instanceof MenuViewState.DataState)
      .cast(MenuViewState.DataState.class)
      .map(this::findSelectedMenuItem)
      .subscribe(this::showCategoryItems);
  clearSelectionRelay = dependencyInjection.getClearSelectionRelay();
}
 
Example 13
Project: android-analytics   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Set up screen UI (recycler, FAB, nav drawer, etc.)
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
            getGaTracker().sendUserEvent(new GaEvent("FAB Category", "FAB Action", "FAB Label", "FAB Custom Dimension"), true);
            //TODO dont make users have to set true/false every time here
        }
    });

    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);

    setCustomDimension1("User 1234");
    setCustomDimension2("Admin");

    // Open main fragment
    getSupportFragmentManager().beginTransaction()
            .add(R.id.container, MainFragment.newInstance())
            .commit();
}
 
Example 14
Project: foodie   File: HomeActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_foodie_home);
    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);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    checkLocationPermission();
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);


    mapView = mapFragment.getView();
    mapView.setContentDescription("MAP NOT READY");
    mapFragment.getMapAsync(this);
    recieveData();

}
 
Example 15
Project: android-fido   File: U2FDemoActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);

    // START Google sign in API client
    // configure sign-in to request user info
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(Constants.SERVER_CLIENT_ID)
            .requestServerAuthCode(Constants.SERVER_CLIENT_ID)
            .build();

    // build client with access to Google Sign-In API and the options specified by gso
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    // END Google sign in API client

    // START prepare main layout
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mProgressBar = findViewById(R.id.progressBar);

    mSwipeRefreshLayout = findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorAccent));
    mSwipeRefreshLayout.setRefreshing(true);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateAndDisplayRegisteredKeys();
        }
    });

    mRecyclerView = findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new SecurityTokenAdapter(new ArrayList<Map<String, String>>(),
            R.layout.row_token, U2FDemoActivity.this);
    // END prepare main layout

    // START prepare drawer layout
    DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null);
    View header = navigationView.getHeaderView(0);
    mUserEmailTextView = header.findViewById(R.id.userEmail);
    mDisplayNameTextView = header.findViewById(R.id.displayName);
    Menu menu = navigationView.getMenu();
    mU2fOperationMenuItem = menu.findItem(R.id.nav_u2fOperations);
    mSignInMenuItem = menu.findItem(R.id.nav_signin);
    mSignOutMenuItem = menu.findItem(R.id.nav_signout);
    mSignInButton = findViewById(R.id.sign_in_button);
    mSignInButton.setSize(SignInButton.SIZE_WIDE);
    mSignInButton.setScopes(gso.getScopeArray());
    mSignInButton.setOnClickListener(this);
    // END prepare drawer layout

    // request SignIn or load registered tokens
    updateUI();
}
 
Example 16
Project: MavsSnapUp   File: ProfileActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    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);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mAuth = FirebaseAuth.getInstance();
    mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");

    loadProfile();

    etFirstName = (EditText) findViewById(R.id.etFirstName);
    etLastName = (EditText) findViewById(R.id.etLastName);
    etAge = (EditText) findViewById(R.id.etAge);
    etPhone = (EditText) findViewById(R.id.etContact);
    btnSaveProfile = (Button) findViewById(R.id.btnSaveProfile);

    btnSaveProfile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String firstName = etFirstName.getText().toString().trim();
            String lastName = etLastName.getText().toString().trim();
            String age = etAge.getText().toString().trim();
            String phone = etPhone.getText().toString().trim();

            String Uid = mAuth.getCurrentUser().getUid();
            DatabaseReference current_user = mDatabase.child(Uid);
            current_user.child("firstname").setValue(firstName);
            current_user.child("lastname").setValue(lastName);
            current_user.child("age").setValue(age);
            current_user.child("phone").setValue(phone);
            Toast.makeText(getApplicationContext(), "PROFILE UPDATED!", Toast.LENGTH_LONG).show();
        }
    });
}
 
Example 17
Project: Runnest   File: SideBarActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_side_bar);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Initialize database
    firebaseHelper = new FirebaseHelper();
    String realEmail = ((AppRunnest) getApplication()).getUser().getEmail();
    email = FirebaseHelper.getFireBaseMail(realEmail);

    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);
    //noinspection deprecation
    drawer.setDrawerListener(toggle);
    toggle.syncState();


    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);
    TextView h1 = (TextView) header.findViewById(R.id.header1_nav_header);
    final TextView h2 = (TextView) header.findViewById(R.id.header2_nav_header);

    runItem = navigationView.getMenu().getItem(1);


    User account = ((AppRunnest)getApplicationContext()).getUser();
    if (account != null) {
        h1.setText(account.getName());

        firebaseHelper.getUserStatistics(account.getEmail(), new FirebaseHelper.statisticsHandler() {
            @Override
            public void handleRetrievedStatistics(String[] statistics) {
                String nbRuns = statistics[firebaseHelper.TOTAL_NUMBER_OF_RUNS_INDEX];
                String header2Txt = nbRuns + " runs";
                h2.setText(header2Txt);
            }
        });
    }

    //Initializing the fragment
    fragmentManager = getSupportFragmentManager();
    currentFragment = fragmentManager.findFragmentById(R.id.fragment_container);

    profileItem = navigationView.getMenu().getItem(0);
    historyItem = navigationView.getMenu().getItem(2);
    profileItem.setChecked(true);
    itemStack.push(profileItem);

    if(currentFragment == null){
        currentFragment = new DBDownloadFragment();
        fragmentManager.beginTransaction().add(R.id.fragment_container, currentFragment).commit();
    }

    handler.post(runnableCode);
}
 
Example 18
Project: GmArchMvvm   File: MainActivity.java   Source Code and License Vote up 4 votes
private void initToolbar() {
    setSupportActionBar(mBinding.appContainer.toolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mBinding.drawerLayout, mBinding.appContainer.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mBinding.drawerLayout.addDrawerListener(toggle);
    toggle.syncState();
}
 
Example 19
Project: crumber   File: MainActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    kek = (CrumbView) findViewById(R.id.view_kek);
    kek.post(new Runnable() {
        @Override
        public void run() {
            generatePath();
        }
    });

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            generatePath();
        }
    });

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    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);
    dotIntervalText = (EditText) navigationView.findViewById(R.id.text_dot_interval);
    dotIntervalText.setText(String.valueOf(kek.getDotInterval()));
    dotRadiusText = (EditText) navigationView.findViewById(R.id.text_dot_radius);
    dotRadiusText.setText(String.valueOf(kek.getDotRadius()));

    drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            kek.setDotInterval(Integer.valueOf(dotIntervalText.getText().toString()));
            kek.setDotRadius(Integer.valueOf(dotRadiusText.getText().toString()));
            kek.invalidate();
        }
    });
}
 
Example 20
Project: AyyMate-Android-RealtimeChat   File: SectionsActivity.java   Source Code and License Vote up 2 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sections);

    mAuth = FirebaseAuth.getInstance();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

   /* FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    }); */

    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);




    // getSupportActionBar().setTitle("Ayymate Chat");

    if (mAuth.getCurrentUser() != null) {


        mUserRef = FirebaseDatabase.getInstance().getReference().child("Users").child(mAuth.getCurrentUser().getUid());

    }


    //Tabs
    mViewPager = (ViewPager) findViewById(R.id.main_tabPager);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager.setAdapter(mSectionsPagerAdapter);

    mTabLayout = (TabLayout) findViewById(R.id.main_tabs);
    mTabLayout.setupWithViewPager(mViewPager);


}