Exemple #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();
      }
    }
Exemple #2
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();
      }
    }