Advertisement
Guest User

MegfejtoActivity.java

a guest
Jul 22nd, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. package org.qnszt.android.akasztofa.activities;
  2.  
  3. import org.json.JSONObject;
  4. import org.qnszt.android.akasztofa.R;
  5. import org.qnszt.android.akasztofa.program.Game;
  6. import org.qnszt.android.json.Json;
  7. import org.qnszt.android.json.JsonManager;
  8.  
  9. import android.app.Activity;
  10. import android.os.Bundle;
  11. import android.text.Editable;
  12. import android.text.TextWatcher;
  13. import android.view.View;
  14. import android.widget.EditText;
  15. import android.widget.TextView;
  16. import android.widget.Toast;
  17.  
  18. public class MegfejtoActivity extends Activity {
  19.  
  20. TextView tvWrong;
  21. TextView tv;
  22. EditText et;
  23. TextView tvcsakprobahoz;
  24. TextView eletlab;
  25. String input;
  26. boolean game;
  27.  
  28. @Override
  29. protected void onCreate(Bundle savedInstanceState) {
  30. super.onCreate(savedInstanceState);
  31. setContentView(R.layout.activity_megfejto);
  32.  
  33. tvcsakprobahoz = (TextView) findViewById(R.id.textView3);
  34. tvWrong = (TextView) findViewById(R.id.tvWrong);
  35. tv = (TextView) findViewById(R.id.textView2);
  36. tv.setText(Game.state);
  37. et = (EditText) findViewById(R.id.editText1);
  38. eletlab = (TextView) findViewById(R.id.eletLab);
  39.  
  40. //eletlab.setText(""+Game.lives);
  41. eletlab.setText(String.valueOf(Game.lives));
  42. game = true;
  43.  
  44. et.addTextChangedListener(new TextWatcher() {
  45.  
  46. public void afterTextChanged(Editable s) {
  47. }
  48. public void beforeTextChanged(CharSequence s, int start,
  49. int count, int after) {
  50. }
  51. public void onTextChanged(CharSequence s, int start,
  52. int before, int count) {
  53. eletlab.setText(String.valueOf(Game.lives));
  54. if (et.getText().toString().length() == 1 && game) {
  55. char c = et.getText().toString().charAt(0);
  56. if (Game.addChar(c)) {
  57. tv.setText(Game.state);
  58. } else {
  59. Game.throwToast(MegfejtoActivity.this, "EZT A BETŰT MÁR TIPPELTED");
  60. }
  61. if (Game.endGame()) {
  62. game = false;
  63. //JsonManager.setContext(MegfejtoActivity.this);
  64. if (Game.lives == 0) {
  65. Toast.makeText(MegfejtoActivity.this,"vesztettél", Toast.LENGTH_LONG).show();
  66. //Json json = JsonManager.createJson("", "", "page", "guest", "", "vereseg");
  67. } else {
  68. Toast.makeText(MegfejtoActivity.this,"nyertél", Toast.LENGTH_LONG).show();
  69. //Json json = JsonManager.createJson("", "", "page", "guest", "", "gyozelem");
  70. }
  71. //JSONObject answer = JsonManager.sendJson(json);
  72. }
  73. et.setText("");
  74. tvWrong.setText(Game.wrong);
  75. }
  76. }
  77.  
  78. });
  79.  
  80. }
  81.  
  82. private void json(String cn, String cpw, String p, String un, String upw, String m) {
  83.  
  84. }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement