Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private FirebaseAuth autenticacao;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_principal);
- Toolbar toolbar = findViewById(R.id.toolbar);
- toolbar.setTitle("aplicativo teste");
- 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.addDrawerListener(toggle);
- toggle.syncState();
- NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
- navigationView.setItemIconTintList(null);
- navigationView.setNavigationItemSelectedListener(this);
- }
- @Override
- public void onBackPressed() {
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
- } else {
- super.onBackPressed();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.principal, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()){
- case R.id.action_Pagamentos :
- startActivity(new Intent(this, PagamentosActivity.class));
- break;
- case R.id.action_Sair :
- autenticacao = ConfiguracaoFirebase.getFirebaseAutenticacao();
- autenticacao.signOut();
- startActivity(new Intent(this, LoginActivity.class));
- finish();
- break;
- }
- return super.onOptionsItemSelected(item);
- }
- @SuppressWarnings("StatementWithEmptyBody")
- @Override
- public boolean onNavigationItemSelected(MenuItem item) {
- // Handle navigation view item clicks here.
- int id = item.getItemId();
- if (id == R.id.nav_destaque) {
- } else if (id == R.id.nav_produtos) {
- } else if (id == R.id.nav_compras) {
- } else if (id == R.id.nav_horario) {
- exibirHorario();
- } else if (id == R.id.nav_avaliar) {
- avaliarApp();
- } else if (id == R.id.nav_compartilhar) {
- compartilharApp();
- } else if (id == R.id.nav_contato) {
- enviarEmail();
- }
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- drawer.closeDrawer(GravityCompat.START);
- return true;
- }
- //Enviar email
- public void enviarEmail(){
- Intent email = new Intent(Intent.ACTION_SEND);
- email.putExtra(Intent.EXTRA_EMAIL, new String[]{"aplicativoteste@gmail.com"});
- email.putExtra(Intent.EXTRA_SUBJECT, "Contato");
- email.putExtra(Intent.EXTRA_TEXT, "Digite sua mensagem aqui");
- email.setType("message/rfc822");
- startActivity(Intent.createChooser(email, "Enviar e-mail com:"));
- }
- //Compartilhar aplicativo
- public void compartilharApp(){
- Intent compartilhar = new Intent(Intent.ACTION_SEND);
- compartilhar.putExtra(Intent.EXTRA_TEXT, "Usei este APP e lembrei de você.");
- compartilhar.setType("text/plain");
- startActivity(Intent.createChooser(compartilhar, "Compartilhar com:"));
- }
- //Avaliar aplicativo
- public void avaliarApp(){
- try {
- startActivity(new Intent(Intent.ACTION_VIEW,
- Uri.parse("market://details?id=" + getPackageName())));
- }catch (ActivityNotFoundException e) {
- startActivity(new Intent(Intent.ACTION_VIEW,
- Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
- }
- }
- //Horario de funcionamento
- public void exibirHorario(){
- AlertDialog.Builder dialog = new AlertDialog.Builder(this);
- dialog.setTitle("Horário de funcionamento");
- dialog.setMessage("Seg. a Qui. -> 17h - 22hnSex. e Sáb. -> 17h - 00h");
- dialog.setCancelable(false);
- dialog.setNeutralButton("Fechar", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int i) {
- dialog.dismiss();
- }
- });
- dialog.create();
- dialog.show();
- }
Add Comment
Please, Sign In to add comment