Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void cogerFechas(){
- String username = i.getStringExtra("us_usuario");
- String password = i.getStringExtra("us_clave");
- Response.Listener<String> responseListener = new Response.Listener<String>(){
- @Override
- public void onResponse(String response){
- try {
- JSONArray jsonArray = new JSONArray(response);
- String fechaAux;
- for(int x=0; x<jsonArray.length(); x++){
- JSONObject jsonObject = jsonArray.getJSONObject(x);
- fechaAux = jsonObject.getString("fecha");
- arrayIntFechas = new ArrayList<>();
- arrayIntFechas.add(separarFecha(fechaAux));
- }
- }catch(JSONException e){
- AlertDialog.Builder builder = new AlertDialog.Builder(Usuario.this);
- builder.setMessage(e.getMessage())
- .setNegativeButton("Retry", null)
- .create().show();
- }catch(ArrayIndexOutOfBoundsException e){
- AlertDialog.Builder builder = new AlertDialog.Builder(Usuario.this);
- builder.setMessage("Error de excepción en el array "+e.getLocalizedMessage())
- .setNegativeButton("Retry", null)
- .create().show();
- }
- if(!arrayIntFechas.isEmpty()){
- Toast t = Toast.makeText(getApplicationContext(), "SOI IO, EL COCU", Toast.LENGTH_SHORT);
- t.show();
- }else if(arrayIntFechas.isEmpty()){
- }
- }
- };
- FechasRequest fechasRequest = new FechasRequest(username, password, responseListener);
- RequestQueue queue = Volley.newRequestQueue(Usuario.this);
- queue.add(fechasRequest);
- }
- public int[] separarFecha(String fecha){
- String[] añoMesDia = fecha.split("-");
- String añoS = añoMesDia[0], mesS = añoMesDia[1], diaS = añoMesDia[2];
- int año = Integer.parseInt(añoS), mes = Integer.parseInt(mesS), dia =
- Integer.parseInt(diaS);
- int [] arrFecha = {año, mes, dia};
- return arrFecha;
- }
Add Comment
Please, Sign In to add comment