Advertisement
Guest User

Untitled

a guest
May 1st, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. package com.CreaLeParole;
  2.  
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.app.ProgressDialog;
  6. import android.content.DialogInterface;
  7. import android.content.Intent;
  8. import android.os.Bundle;
  9. import android.view.Menu;
  10. import android.view.MenuInflater;
  11. import android.view.View;
  12. import android.view.Window;
  13. import android.widget.Button;
  14. import android.widget.TextView;
  15.  
  16. import com.CreaLeParole.library.DatabaseHandler;
  17. import com.CreaLeParole.library.UserFunctions;
  18. import com.learn2crack.R;
  19.  
  20. import java.util.HashMap;
  21.  
  22. public class menu_principale extends Activity {
  23. // Button btnLogout;
  24. // Button changepas;
  25. Button buttonImpostazioniMenuPrincipale;
  26. UserFunctions userFunctions;
  27.  
  28.  
  29.  
  30. /**
  31. * Called when the activity is first created.
  32. */
  33. @Override
  34. public void onCreate(Bundle savedInstanceState) {
  35. super.onCreate(savedInstanceState);
  36.  
  37. // Con questi 2 imposto l'activity a schermo intero (FULL SCREEN)
  38. requestWindowFeature(Window.FEATURE_NO_TITLE);
  39.  
  40. /**
  41. * MENU PRINCIPALE ACTIVITY Screen for the application
  42. * */
  43. // Check login status in database
  44. userFunctions = new UserFunctions();
  45.  
  46. if(userFunctions.isUserLoggedIn(getApplicationContext())){
  47. setContentView(R.layout.activity_menu_principale);
  48. }else{
  49. // user is not logged in show login screen
  50. Intent login = new Intent(getApplicationContext(), Login.class);
  51. login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  52. startActivity(login);
  53. // Closing dashboard screen
  54. finish();
  55. }
  56.  
  57.  
  58. //bottoni
  59. buttonImpostazioniMenuPrincipale = (Button) findViewById(R.id.buttonImpostazioniMenuPrincipale);
  60.  
  61. /**
  62. *
  63. **/
  64. buttonImpostazioniMenuPrincipale.setOnClickListener(new View.OnClickListener(){
  65. public void onClick(View view){
  66. Intent imp = new Intent(getApplicationContext(), com.CreaLeParole.Impostazioni.class);
  67. startActivity(imp);
  68. }
  69. });
  70.  
  71.  
  72. // changepas = (Button) findViewById(R.id.btchangepass);
  73. // btnLogout = (Button) findViewById(R.id.logout);
  74. //
  75. //
  76. // DatabaseHandler db = new DatabaseHandler(getApplicationContext());
  77. //
  78. // /**
  79. // * Hashmap to load data from the Sqlite database
  80. // **/
  81. // HashMap<String,String> user = new HashMap<String, String>();
  82. // user = db.getUserDetails();
  83. //
  84. //
  85. // /**
  86. // * Change Password Activity Started
  87. // **/
  88. // changepas.setOnClickListener(new View.OnClickListener(){
  89. // public void onClick(View arg0){
  90. //
  91. // Intent chgpass = new Intent(getApplicationContext(), ChangePassword.class);
  92. //
  93. // startActivity(chgpass);
  94. // }
  95. //
  96. // });
  97. //
  98. // /**
  99. // *Logout from the User Panel which clears the data in Sqlite database
  100. // **/
  101. // btnLogout.setOnClickListener(new View.OnClickListener() {
  102. //
  103. // public void onClick(View arg0) {
  104. //
  105. // UserFunctions logout = new UserFunctions();
  106. // logout.logoutUser(getApplicationContext());
  107. // Intent login = new Intent(getApplicationContext(), Login.class);
  108. // login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  109. // startActivity(login);
  110. // finish();
  111. // }
  112. // });
  113. //
  114. // /**
  115. // * Sets user first name and last name in text view.
  116. // **/
  117. // final TextView login = (TextView) findViewById(R.id.textwelcome);
  118. // login.setText("Welcome "+user.get("fname"));
  119. // final TextView lname = (TextView) findViewById(R.id.lname);
  120. // lname.setText(user.get("lname"));
  121.  
  122. }
  123. //
  124. // @Override
  125. // public boolean onCreateOptionsMenu(Menu menu) {
  126. // // Inflate the menu items for use in the action bar
  127. // MenuInflater inflater = getMenuInflater();
  128. // inflater.inflate(R.menu.menu_principale, menu);
  129. // return super.onCreateOptionsMenu(menu);
  130. // }
  131.  
  132. /**
  133. * Individua l'Activity nella quale andare quando si preme il pulsante "back"
  134. */
  135. @Override
  136. public void onBackPressed() {
  137. DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
  138. @Override
  139. public void onClick(DialogInterface dialog, int which) {
  140. switch (which){
  141. case DialogInterface.BUTTON_POSITIVE:
  142. //Inserire modo per uscire correttamente -------------- COMPLETARE!!!!!
  143. break;
  144.  
  145. case DialogInterface.BUTTON_NEGATIVE:
  146. //No button clicked
  147. break;
  148. }
  149. }
  150. };
  151.  
  152. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  153. builder.setMessage("Vuoi uscire dal gioco").setPositiveButton("Si", dialogClickListener)
  154. .setNegativeButton("No", dialogClickListener).show();
  155. }
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement