Exemplo n.º 1
0
    @Override
    protected void onPostExecute(String s) {
      if (state) {
        try {
          estaciones = XMLParser.getItem(s, "Station");

          List<String> e = new ArrayList<>();
          for (Item item : estaciones) {
            e.add(item.getName());
          }
          ArrayAdapter<String> adapter =
              new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, e);
          station.setAdapter(adapter);
          station.setSelection(adapter.getPosition(reg.getString("SELECT" + station.getId())));

        } catch (Exception e) {
          Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
      } else {
        Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
      }

      if (progressDialog.isShowing()) {
        progressDialog.dismiss();
      }
    }
Exemplo n.º 2
0
    @Override
    protected String doInBackground(String... strings) {
      TelephonyManager telephonyManager =
          (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
      try {
        String query =
            SoapRequest1.sendCheckList(
                telephonyManager.getDeviceId(),
                estaciones.get(station.getSelectedItemPosition()).getId(),
                modulos,
                imagenes);

        ArrayList<String> response = XMLParser.getReturnCode2(query);

        ok = response.get(0).equals("0");
        if (ok) return query;
        else return response.get(1);

      } catch (SAXException e) {
        e.printStackTrace();
        return "Error al leer el XML";
      } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return "Error al leer el XML";
      } catch (XPathExpressionException e) {
        e.printStackTrace();
        return "Error al leer el XML";
      } catch (IOException e) {
        e.printStackTrace();
        return "Error al leer el XML";
      } catch (Exception e) {
        e.printStackTrace();
        return "Ha ocurrido un error";
      }
    }
Exemplo n.º 3
0
    @Override
    protected String doInBackground(String... strings) {
      try {
        TelephonyManager telephonyManager =
            (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String query = SoapRequest1.getDepartament(telephonyManager.getDeviceId());
        ArrayList<String> parse = XMLParser.getReturnCode2(query);
        Log.d("ELEMENTS", query);
        if (parse.get(0).equals("0")) {
          state = true;
          return query;
        } else return parse.get(1);

      } catch (IOException e) {
        e.printStackTrace();
        return "No se pudo conectar con el servidor, compruebe se conexión a internet y reintente";
      } catch (SAXException e) {
        e.printStackTrace();
        return "Error al leer el XML, por favor reintente";
      } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return "Error al leer el XML, por favor reintente";
      } catch (XPathExpressionException e) {
        e.printStackTrace();
        return "Error al leer el XML, por favor reintente";
      } catch (Exception e) {
        e.printStackTrace();
        return "Ha ocurrido un error, por favor reintente";
      }
    }
Exemplo n.º 4
0
    @Override
    protected void onPostExecute(String s) {
      if (state) {
        try {
          departamentos = XMLParser.getItem(s, "Department");

          List<String> e = new ArrayList<>();
          for (Item item : departamentos) {
            e.add(item.getName());
          }
          ArrayAdapter<String> adapter =
              new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, e);
          depto.setAdapter(adapter);

          depto.setSelection(adapter.getPosition(reg.getString("SELECT" + depto.getId())));
        } catch (IOException e) {
          Toast.makeText(
                  getApplicationContext(),
                  "No se pudo conectar con el servidor, compruebe se conexión a internet y reintente",
                  Toast.LENGTH_LONG)
              .show();
          esta.finish();
        } catch (ParserConfigurationException e) {
          Toast.makeText(
                  getApplicationContext(),
                  "Error al leer el XML, por favor reintente",
                  Toast.LENGTH_LONG)
              .show();
          esta.finish();
        } catch (Exception e) {
          Toast.makeText(
                  getApplicationContext(),
                  "Ha ocurrido un error, por favor reintente",
                  Toast.LENGTH_LONG)
              .show();
          esta.finish();
        }
      } else {
        Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
        esta.finish();
      }

      if (progressDialog.isShowing()) {
        progressDialog.dismiss();
      }
    }
Exemplo n.º 5
0
    @Override
    protected void onPostExecute(String s) {
      if (state) {
        try {
          modulos = XMLParser.getRelevoCheck(s);
          dibujarCheck();

        } catch (Exception e) {
          Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
      } else {
        Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
      }

      if (progressDialog.isShowing()) {
        progressDialog.dismiss();
      }
    }
Exemplo n.º 6
0
    @Override
    protected String doInBackground(Integer... strings) {
      try {
        TelephonyManager telephonyManager =
            (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String query = SoapRequest1.getCheckList(telephonyManager.getDeviceId(), strings[0]);
        ArrayList<String> parse = XMLParser.getReturnCode2(query);
        if (parse.get(0).equals("0")) {
          state = true;
          return query;
        } else return parse.get(1);

      } catch (Exception e) {
        Log.e("CHECKLIST", e.getMessage() + ": \n" + e.getCause());
        state = false;
        return e.getMessage();
      }
    }
Exemplo n.º 7
0
    @Override
    protected void onPostExecute(String s) {

      if (ok) {
        boton.setEnabled(false);
        reg.addValue("SEND", true);
        try {
          idRelevo = XMLParser.getIdRelevo(s);
          reg.addValue("IDRELEVO", idRelevo);
          Toast.makeText(context, "Se envió correctamente", Toast.LENGTH_LONG).show();
        } catch (ParserConfigurationException e) {
          e.printStackTrace();
        } catch (SAXException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }

      } else {
        Toast.makeText(context, s, Toast.LENGTH_LONG).show();
      }
      if (d.isShowing()) d.dismiss();
    }