Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onDateChanged(DatePicker view, int year, int month, int day){
- String username = i.getStringExtra("us_usuario");
- String password = i.getStringExtra("us_clave");
- int Año = calendario.getYear();
- int Mes = calendario.getMonth()+1;
- int Dia = calendario.getDayOfMonth();
- String fecha = Año+"-"+Mes+"-"+Dia;
- Response.Listener<String> responseListener = new Response.Listener<String>(){
- @Override
- public void onResponse(String response){
- try {
- JSONArray jsonArray = new JSONArray(response);
- String hora_inicio, hora_fin, fecha, nombre, apellidos, prestacion;
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- hora_inicio = jsonObject.getString("hora_inicio");
- hora_fin = jsonObject.getString("hora_fin");
- fecha = jsonObject.getString("fecha");
- nombre = jsonObject.getString("nombre");
- apellidos = jsonObject.getString("apellidos");
- prestacion = jsonObject.getString("prestacion");
- String[] arrayRespuesta = {hora_inicio, hora_fin, nombre, apellidos, prestacion};
- int[] comprobarFecha = separarFecha(fecha);
- TablaPacientes tabla = new TablaPacientes(Usuario.this, tablePaciente);
- if(comprobarFecha[0] == calendario.getYear() && comprobarFecha[1] == calendario.getMonth()+1 && comprobarFecha[2] == calendario.getDayOfMonth()){
- //tablePaciente.removeAllViews();
- tabla.agregarCabecera(R.array.tabla_pacientes);
- cargarTabla(tabla, arrayRespuesta);
- }else{
- tablePaciente.removeAllViews();
- Toast t = Toast.makeText(getApplicationContext(), "No hay pacientes para esta fecha", Toast.LENGTH_LONG);
- t.show();
- }
- }
- }catch(JSONException e){
- tablePaciente.removeAllViews();
- Toast t = Toast.makeText(getApplicationContext(), "No hay pacientes para esta fecha", Toast.LENGTH_LONG);
- t.show();
- }catch(ArrayIndexOutOfBoundsException e){
- tablePaciente.removeAllViews();
- AlertDialog.Builder builder = new AlertDialog.Builder(Usuario.this);
- builder.setMessage("Error de excepción en el array "+e.getLocalizedMessage())
- .setNegativeButton("Retry", null)
- .create().show();
- }
- }
- };
- RegisterRequest registerRequest = new RegisterRequest(username, password, fecha, responseListener);
- RequestQueue queue = Volley.newRequestQueue(Usuario.this);
- queue.add(registerRequest);
- }
Add Comment
Please, Sign In to add comment