Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String iip = "192.168.1.34";
- String param = comandaActiva.getIdComanda();
- String consulta = "http://" + iip + "/Antonia/consultaComanda.php?id=" + param;
- EnviarRecibirDatos(consulta);
- }
- });
- }
- };
- timer.schedule(task, 100, 1000); //ejecutar en intervalo de 1 segundo.
- if (queue == null) {
- queue = Volley.newRequestQueue(this);
- }
- StringRequest stringRequest = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- //Toast.makeText(getApplicationContext(), "on response", Toast.LENGTH_SHORT).show();
- ja = new JSONArray();
- response = response.replace("][",",");
- if (response.length()>0){
- //Toast.makeText(getApplicationContext(), "response>0", Toast.LENGTH_SHORT).show();
- try {
- ja = new JSONArray(response);
- if(ja.length()>0){
- //Log.i("sizejson",""+ja.length());
- CargarListView(ja);}
- else
- {
- }
- } catch (JSONException e) {
- }
- }
- }
- }, new Response.ErrorListener(){
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- });
- queue.add(stringRequest);
- }
- lista = new ArrayList<>();
- for (int h = 0 ; h<lista.size();h++)
- {
- lista.remove(h);
- }
- if(ja.length()>0){
- for(int i=0;i<ja.length();i+=4){
- try {
- String temporal=ja.getString(i+1);
- lista.add(ja.getString(i)+") "+ja.getString(i+2)+"X"+temporal+"n"+ja.getString(i+3)+" ");
- } catch (Exception e) {
- lista.clear();
- lista.add("");
- }
- }}
- else
- {
- for(int r=0; r<lista.size();r++){
- lista.remove(r);}
- }
- int scroll = lvProductos.getMaxScrollAmount();
- adaptador = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lista);
- lvProductos.setAdapter(adaptador);
Add Comment
Please, Sign In to add comment