Guest User

Untitled

a guest
Mar 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. String iip = "192.168.1.34";
  2. String param = comandaActiva.getIdComanda();
  3. String consulta = "http://" + iip + "/Antonia/consultaComanda.php?id=" + param;
  4.  
  5. EnviarRecibirDatos(consulta);
  6. }
  7. });
  8. }
  9. };
  10.  
  11. timer.schedule(task, 100, 1000); //ejecutar en intervalo de 1 segundo.
  12.  
  13. if (queue == null) {
  14. queue = Volley.newRequestQueue(this);
  15.  
  16. }
  17.  
  18.  
  19. StringRequest stringRequest = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
  20. @Override
  21. public void onResponse(String response) {
  22. //Toast.makeText(getApplicationContext(), "on response", Toast.LENGTH_SHORT).show();
  23. ja = new JSONArray();
  24. response = response.replace("][",",");
  25. if (response.length()>0){
  26. //Toast.makeText(getApplicationContext(), "response>0", Toast.LENGTH_SHORT).show();
  27. try {
  28. ja = new JSONArray(response);
  29. if(ja.length()>0){
  30.  
  31. //Log.i("sizejson",""+ja.length());
  32. CargarListView(ja);}
  33. else
  34. {
  35.  
  36.  
  37.  
  38. }
  39.  
  40. } catch (JSONException e) {
  41.  
  42.  
  43. }
  44.  
  45. }
  46.  
  47.  
  48. }
  49. }, new Response.ErrorListener(){
  50. @Override
  51. public void onErrorResponse(VolleyError error) {
  52.  
  53.  
  54. }
  55. });
  56.  
  57. queue.add(stringRequest);
  58. }
  59.  
  60. lista = new ArrayList<>();
  61. for (int h = 0 ; h<lista.size();h++)
  62. {
  63. lista.remove(h);
  64. }
  65. if(ja.length()>0){
  66. for(int i=0;i<ja.length();i+=4){
  67.  
  68. try {
  69. String temporal=ja.getString(i+1);
  70.  
  71. lista.add(ja.getString(i)+") "+ja.getString(i+2)+"X"+temporal+"n"+ja.getString(i+3)+" ");
  72. } catch (Exception e) {
  73. lista.clear();
  74. lista.add("");
  75. }
  76.  
  77. }}
  78. else
  79. {
  80. for(int r=0; r<lista.size();r++){
  81. lista.remove(r);}
  82. }
  83.  
  84. int scroll = lvProductos.getMaxScrollAmount();
  85.  
  86.  
  87.  
  88. adaptador = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lista);
  89.  
  90. lvProductos.setAdapter(adaptador);
Add Comment
Please, Sign In to add comment