Guest User

Untitled

a guest
Oct 27th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState){
  3. super.onCreate(savedInstanceState);
  4. setContentView(R.layout.activity_usuario);
  5. lblBienvenida = (TextView)findViewById(R.id.lblBienvenida);
  6. calendario = (DatePicker)findViewById(R.id.calendario);
  7. tablePaciente = (TableLayout)findViewById(R.id.tablePaciente);
  8. i = getIntent();
  9. calendario.init(0, 0, 0, new DatePicker.OnDateChangedListener(){
  10. @Override
  11. public void onDateChanged (DatePicker datePicker, int año, int mes, int dia){
  12. String username = i.getStringExtra("us_usuario");
  13. String password = i.getStringExtra("us_clave");
  14. lblBienvenida.setText("Bienvenid@: "+username);
  15. int Año = calendario.getYear();
  16. int Mes = calendario.getMonth()+1;
  17. int Dia = calendario.getDayOfMonth();
  18. Response.Listener<String> responseListener = new Response.Listener<String>(){
  19. @Override
  20. public void onResponse(String response){
  21. try{
  22. JSONObject jsonResponse = new JSONObject(response);
  23. boolean success = jsonResponse.getBoolean("success");
  24. if(success){
  25. String [] arrayRespuesta = new String [jsonResponse.length()];
  26. for(int x = 0; x<jsonResponse.length()-9; x++){
  27. arrayRespuesta [x] = jsonResponse.getString(x+"");
  28. }
  29. tablePaciente.removeAllViews();
  30. TablaPacientes tabla = new TablaPacientes(Usuario.this, tablePaciente);
  31. cargarTabla(tabla, arrayRespuesta);
  32. }else{
  33. AlertDialog.Builder builder = new AlertDialog.Builder(Usuario.this);
  34. builder.setMessage("error Login")
  35. .setNegativeButton("Retry", null)
  36. .create().show();
  37. }
  38. }catch(JSONException e){
  39. AlertDialog.Builder builder = new AlertDialog.Builder(Usuario.this);
  40. builder.setMessage(e.getMessage())
  41. .setNegativeButton("Retry", null)
  42. .create().show();
  43. }
  44. }
  45. };
  46. String fecha = Año+"-"+Mes+"-"+Dia;
  47. RegisterRequest registerRequest = new RegisterRequest(username, password, fecha, responseListener);
  48. RequestQueue queue = Volley.newRequestQueue(Usuario.this);
  49. queue.add(registerRequest);
  50. }
  51. });
  52. }
Add Comment
Please, Sign In to add comment