コード例 #1
0
 public static void getNuevosDatos(
     Context context, String zona, String version, ProgressDialog pd) {
   HttpGet get =
       ServerConnection.getGet(
           context.getResources().getString(R.string.ip_server),
           context.getResources().getString(R.string.port_server),
           "actualizarDatosGeo/" + zona + "/" + version);
   RequestArrayJSONResponse taskResquest = new RequestArrayJSONResponse();
   taskResquest.setParams(
       new ResponseServer_actualizarDatos_TaskListener(context, zona, pd),
       ServerConnection.getClient(),
       get);
   taskResquest.execute();
 }
コード例 #2
0
    protected void onPostExecute(Void result) {
      super.onPostExecute(result);
      pd.dismiss();
      if ((buffer.length() > 0) && (fallos < buffer.length() / 4)) {
        pd =
            ProgressDialog.show(
                context,
                context.getResources().getText(R.string.esperar),
                context.getResources().getText(R.string.comprobar_actualizaciones));
        pd.setIndeterminate(false);
        pd.setCancelable(false);

        if (!fich) {
          if (!paco.lugares.comer.opendata.chascarentenerife.server.Utilities.haveInternet(
              context)) {
            pd.dismiss();
            Toast.makeText(context, R.string.no_internet, Toast.LENGTH_LONG).show();
            return;
          }

          RequestSimpleResponse taskResquest = new RequestSimpleResponse();
          HttpGet get =
              ServerConnection.getGet(
                  context.getResources().getString(R.string.ip_server),
                  context.getResources().getString(R.string.port_server),
                  "infoDatos/" + zona);
          taskResquest.setParams(
              new ResponseServer_version_TaskListener(context, pd),
              ServerConnection.getClient(),
              get);
          taskResquest.execute();
        } else {
          Version encontrado = Entity.query(Version.class).where(eql("zona", "Tenerife")).execute();
          if (encontrado == null) {
            Version nuevaVersion = new Version("1", "Tenerife");
            nuevaVersion.save();
          } else {
            encontrado.version = "1";
            Calendar c = Calendar.getInstance();
            c.setTime(new Date());
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
            encontrado.fecha = sdf.format(c.getTime());
            encontrado.save();
          }
          pd.dismiss();
        }
      } else {
        Toast.makeText(context, R.string.fallos, Toast.LENGTH_LONG).show();
      }
    }