Guest User

Untitled

a guest
Jan 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. private FirebaseAuth autenticacao;
  2.  
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. setContentView(R.layout.activity_principal);
  7. Toolbar toolbar = findViewById(R.id.toolbar);
  8. toolbar.setTitle("aplicativo teste");
  9. setSupportActionBar(toolbar);
  10. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  11. fab.setOnClickListener(new View.OnClickListener() {
  12. @Override
  13. public void onClick(View view) {
  14. Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
  15. .setAction("Action", null).show();
  16. }
  17. });
  18.  
  19. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  20. ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
  21. this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  22. drawer.addDrawerListener(toggle);
  23. toggle.syncState();
  24.  
  25. NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  26. navigationView.setItemIconTintList(null);
  27. navigationView.setNavigationItemSelectedListener(this);
  28.  
  29. }
  30.  
  31. @Override
  32. public void onBackPressed() {
  33. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  34. if (drawer.isDrawerOpen(GravityCompat.START)) {
  35. drawer.closeDrawer(GravityCompat.START);
  36. } else {
  37. super.onBackPressed();
  38. }
  39. }
  40.  
  41. @Override
  42. public boolean onCreateOptionsMenu(Menu menu) {
  43. // Inflate the menu; this adds items to the action bar if it is present.
  44. getMenuInflater().inflate(R.menu.principal, menu);
  45. return true;
  46. }
  47.  
  48. @Override
  49. public boolean onOptionsItemSelected(MenuItem item) {
  50. switch (item.getItemId()){
  51. case R.id.action_Pagamentos :
  52. startActivity(new Intent(this, PagamentosActivity.class));
  53. break;
  54. case R.id.action_Sair :
  55. autenticacao = ConfiguracaoFirebase.getFirebaseAutenticacao();
  56. autenticacao.signOut();
  57. startActivity(new Intent(this, LoginActivity.class));
  58. finish();
  59. break;
  60. }
  61. return super.onOptionsItemSelected(item);
  62. }
  63.  
  64. @SuppressWarnings("StatementWithEmptyBody")
  65. @Override
  66. public boolean onNavigationItemSelected(MenuItem item) {
  67. // Handle navigation view item clicks here.
  68. int id = item.getItemId();
  69.  
  70. if (id == R.id.nav_destaque) {
  71.  
  72. } else if (id == R.id.nav_produtos) {
  73.  
  74. } else if (id == R.id.nav_compras) {
  75.  
  76. } else if (id == R.id.nav_horario) {
  77. exibirHorario();
  78. } else if (id == R.id.nav_avaliar) {
  79. avaliarApp();
  80. } else if (id == R.id.nav_compartilhar) {
  81. compartilharApp();
  82. } else if (id == R.id.nav_contato) {
  83. enviarEmail();
  84. }
  85.  
  86. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  87. drawer.closeDrawer(GravityCompat.START);
  88. return true;
  89. }
  90.  
  91. //Enviar email
  92. public void enviarEmail(){
  93.  
  94. Intent email = new Intent(Intent.ACTION_SEND);
  95. email.putExtra(Intent.EXTRA_EMAIL, new String[]{"aplicativoteste@gmail.com"});
  96. email.putExtra(Intent.EXTRA_SUBJECT, "Contato");
  97. email.putExtra(Intent.EXTRA_TEXT, "Digite sua mensagem aqui");
  98.  
  99. email.setType("message/rfc822");
  100.  
  101. startActivity(Intent.createChooser(email, "Enviar e-mail com:"));
  102. }
  103.  
  104. //Compartilhar aplicativo
  105. public void compartilharApp(){
  106.  
  107. Intent compartilhar = new Intent(Intent.ACTION_SEND);
  108. compartilhar.putExtra(Intent.EXTRA_TEXT, "Usei este APP e lembrei de você.");
  109.  
  110. compartilhar.setType("text/plain");
  111.  
  112. startActivity(Intent.createChooser(compartilhar, "Compartilhar com:"));
  113. }
  114.  
  115. //Avaliar aplicativo
  116. public void avaliarApp(){
  117. try {
  118. startActivity(new Intent(Intent.ACTION_VIEW,
  119. Uri.parse("market://details?id=" + getPackageName())));
  120. }catch (ActivityNotFoundException e) {
  121. startActivity(new Intent(Intent.ACTION_VIEW,
  122. Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
  123. }
  124. }
  125.  
  126. //Horario de funcionamento
  127. public void exibirHorario(){
  128. AlertDialog.Builder dialog = new AlertDialog.Builder(this);
  129. dialog.setTitle("Horário de funcionamento");
  130. dialog.setMessage("Seg. a Qui. -> 17h - 22hnSex. e Sáb. -> 17h - 00h");
  131. dialog.setCancelable(false);
  132. dialog.setNeutralButton("Fechar", new DialogInterface.OnClickListener() {
  133. @Override
  134. public void onClick(DialogInterface dialog, int i) {
  135. dialog.dismiss();
  136. }
  137. });
  138.  
  139. dialog.create();
  140. dialog.show();
  141.  
  142. }
Add Comment
Please, Sign In to add comment