Exemple #1
0
  /**
   * It converts double to char by the gray's code
   *
   * @param ds the vector which is goint to change
   * @param length the size of the vector
   * @return the changed vector
   */
  private char[] StringRep(double[] ds, int length) {

    int i;
    double n;
    int pos;
    double INCREMENTO;
    char[] Cad_sal;
    Cad_sal = new char[Genes * BITS_GEN + 1];
    if (flag == 1) {
      tmpstring = new char[Genes * BITS_GEN];
      flag = 0;
    }

    pos = 0;
    for (i = 0; i < length; i++) {
      INCREMENTO = (Gene[i].max() - Gene[i].min()) / (Math.pow(2.0, (double) BITS_GEN) - 1.0);

      n = (((ds[i] - Gene[i].min()) / INCREMENTO) + 0.5);
      tmpstring = F.Itoc((int) n, BITS_GEN);

      F.Gray(tmpstring, Cad_sal, BITS_GEN, pos);
      pos += BITS_GEN;
    }
    return Cad_sal;
  }
 private void logButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_logButtonActionPerformed
   // TODO add your handling code here:
   Funciones f = new Funciones();
   LogClientes lg = new LogClientes();
   lg.setVisible(true);
   String select = "select * from log_clientes;";
   f.poblarTabla(select, LogClientes.getTabla());
 } // GEN-LAST:event_logButtonActionPerformed
 public void openFAQ(View view) {
   if (bloqueo.getState("Preguntas")) {
     Funciones.makeResultAlert(mContext, bloqueo.getMsg("Preguntas"), false).show();
   } else {
     startActivity(new Intent(this, FAQActivity.class));
   }
 }
    protected void onPostExecute(String result) {
      if (result != null) {
        if (code == 0) {
          Intent topologica = new Intent(getApplicationContext(), VistaTopologica.class);
          topologica.putExtra("PHONE", phone.getText().toString());
          topologica.putExtra("RESULT", result);
          startActivityForResult(topologica, 0);
          Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
          vibrator.vibrate(50);
        } else {
          Funciones.makeResultAlert(mContext, result, false).show();
        }
      } else {
        Funciones.makeResultAlert(mContext, errorMessage, false).show();
      }

      if (this.dialog.isShowing()) {
        this.dialog.dismiss();
      }
    }
  public void show_plantas_externas(View view) {
    if (bloqueo.getState("PlantasExternas")) {
      Funciones.makeResultAlert(mContext, bloqueo.getMsg("PantasExternas"), false).show();
    } else {
      ConnectivityManager conMan =
          (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

      State senal3g = conMan.getNetworkInfo(0).getState();
      State wifi = conMan.getNetworkInfo(1).getState();

      if (senal3g == State.CONNECTED || wifi == State.CONNECTED) {
        Intent i = new Intent(this, Plantas_Externas.class);
        startActivityForResult(i, 0);

      } else {
        Funciones.makeResultAlert(
                mContext, "No existe conexión a internet para utilizar el Programa", false)
            .show();
      }
    }
  }
  public void buscar_cliente(View view) {
    if (bloqueo.getState("busquedaInicial")) {
      Funciones.makeResultAlert(mContext, bloqueo.getMsg("busquedaInicial"), false).show();
    } else {
      ConnectivityManager conMan =
          (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

      State senal3g = conMan.getNetworkInfo(0).getState();
      State wifi = conMan.getNetworkInfo(1).getState();
      if (senal3g == State.CONNECTED || wifi == State.CONNECTED) {
        if (phone.getText().length() == 0 || phone.getText() == null) {
          Funciones.makeResultAlert(mContext, "Ingrese un número de teléfono", false).show();
          return;
        }

        Consulta_Resources c = new Consulta_Resources();
        c.execute();
      } else {
        Funciones.makeResultAlert(
                mContext, "No existe conexión a internet para utilizar el Programa", false)
            .show();
      }
    }
  }
 @Override
 protected File doInBackground(String... params) {
   return Funciones.Update(url);
 }
  public void shutdown(View view) {
    ArrayList<Activity> actividades = new ArrayList<>();
    actividades.add(p);

    Funciones.makeExitAlert(mContext, actividades).show();
  }
    @Override
    protected void onPostExecute(String s) {
      if (d.isShowing()) d.dismiss();
      if (!ok) {
        Funciones.makeAlert(mContext, null, s, false)
            .setPositiveButton(
                "Aceptar",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    p.finish();
                  }
                })
            .show();
      } else if (actualizar != null && actualizar.isActualizacion()) {
        String versionActual = getResources().getString(R.string.versioncode);
        try {
          if (versionActual.compareTo(actualizar.getId()) < 0) {
            AlertDialog.Builder builder =
                Funciones.makeAlert(
                    mContext,
                    "Hay una nueva versión de la Aplicación",
                    "Versión Instalada: "
                        + versionActual
                        + "\nVersión a Instalar: "
                        + actualizar.getId()
                        + "\nDebe actualizar la aplicación para continuar utilizandola.",
                    false);

            builder.setPositiveButton(
                "Descargar e Instalar",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    /*Toast.makeText(mContext, "Descargando... si claro", Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/app-debug.apk")), "application/vnd.android.package-archive");
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    p.finish();
                    dialog.dismiss();*/
                    Update u = new Update(context, actualizar.getName());
                    u.execute();
                  }
                });
            builder.setNegativeButton(
                "Cerrar",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    p.finish();
                    dialog.dismiss();
                  }
                });
            builder.setOnCancelListener(
                new DialogInterface.OnCancelListener() {
                  @Override
                  public void onCancel(DialogInterface dialog) {
                    p.finish();
                  }
                });
            builder.show();
          }
        } catch (Exception e) {
          Funciones.makeAlert(mContext, e.getMessage(), e.getCause().toString(), false)
              .setPositiveButton(
                  "Aceptar",
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {}
                  })
              .show();
        }
      }
      // Log.i("BLOQUEO", s);
    }