protected JSONObject doInBackground(String... args) { JSONObject json = new JSONObject(); try { HttpUploader uploader = new HttpUploader( getActivity().getResources(), BuildConfig.DOMAIN + Constantes.PUBLISH_COMMENT); uploader.añadirArgumento( "idevento", event.getId()); // le pasamos el codigo del evento del cual estamos mostrando el detalle uploader.añadirArgumento("message", etCommentTxt.getText().toString().trim()); uploader.añadirArgumento("devid", Utilidades.getDevId(getActivity())); uploader.añadirArgumento("timezoneoffset", Utilidades.getTimeZoneOffset(getActivity())); json = uploader.enviar(); } catch (ConnectionException e) { e.printStackTrace(); try { json.put(Constantes.JSON_MESSAGE, e.getMessage()); json.put(Constantes.JSON_SUCCESS, 0); } catch (JSONException e1) { e1.printStackTrace(); } } return json; }
private void cargarHistorialResultadosParaclinicos( Row fila, Presultados_paraclinicos presultados_paraclinicos) { if (presultados_paraclinicos == null) { fila.appendChild(Utilidades.obtenerCell("", Label.class, true, true)); fila.appendChild(Utilidades.obtenerCell("", Label.class, true, true)); } else { Pexamenes_paraclinicos pexamenes_paraclinicos = new Pexamenes_paraclinicos(); pexamenes_paraclinicos.setCodigo_empresa(presultados_paraclinicos.getCodigo_empresa()); pexamenes_paraclinicos.setCodigo_sucursal(presultados_paraclinicos.getCodigo_sucursal()); pexamenes_paraclinicos.setCodigo(presultados_paraclinicos.getCodigo_examen()); pexamenes_paraclinicos = zkWindow .getServiceLocator() .getPexamenes_paraclinicosService() .consultar(pexamenes_paraclinicos); fila.appendChild( Utilidades.obtenerCell(presultados_paraclinicos.getFecha(), Datebox.class, true, false)); Cell celda = Utilidades.obtenerCell( presultados_paraclinicos.getResultado(), Textbox.class, true, false); Textbox textbox_resultado = (Textbox) celda.getFirstChild(); textbox_resultado.setAttribute( "VALOR_NORMAL_ANORMAL", presultados_paraclinicos.getNormal_anormal()); textbox_resultado.setAttribute( "VALOR_DESCRIPCION_NA", presultados_paraclinicos.getDescripcion_na()); textbox_resultado.setPopup( generarPopupResultados(textbox_resultado, false, pexamenes_paraclinicos)); fila.appendChild(celda); } }
public void cadastrarTime(Time time) throws UsuarioCurtoException, UsuarioLongoException, UsuarioExistenteException, SenhaCurtaException, SenhaLongaException { boolean usuarioExistente = (Boolean) null; boolean nomeUsuarioJaExiste = (Boolean) null; if (time == null) { throw new IllegalArgumentException(); // o que fazer quando null? } else { if (Utilidades.nomeUsuarioNosConformes(time.getUsuario())) { } else { throw new UsuarioCurtoException(); } Utilidades.nomeNosConformes(time.getNome()); // chamar método nomeUsuarioNosConforme e senha tb. nomeUsuarioJaExiste = repositorioTime.verificarNomeUsuarioJaExiste(time.getUsuario()); if (usuarioExistente == false && nomeUsuarioJaExiste == false) { repositorioTime.cadastrarTime(time); } else if (usuarioExistente) { throw new UsuarioExistenteException(); } if (nomeUsuarioJaExiste) { throw new UsuarioExistenteException(); } } }
@Override public StringBuilder encode(String mensagemAscii) { StringBuilder mensagemEmBinario = Utilidades.converteAsciiParaBinario(mensagemAscii); String auxiliar = StringUtils.rightPad("", polinomio.length() - 1, "0"); StringBuilder restoDivisao = Utilidades.retornaRestoDivisaoBits( new StringBuilder(mensagemEmBinario + auxiliar), polinomio); return mensagemEmBinario.append(restoDivisao.substring(1, polinomio.length())); }
protected void onPostExecute(JSONObject json) { int success; String mensaje; byte[] imageByteArray = null; try { success = json.getInt(Constantes.JSON_SUCCESS); mensaje = json.getString(Constantes.JSON_MESSAGE); if (success == 1) { // si fue bien JSONObject jsoncomment = json.getJSONObject("comment"); String imagepath = getActivity().getFilesDir() + "/images/" + Constantes.IMAGEN_PERFIL_FILENAME; File imagefile = new File(imagepath); if (imagefile.exists()) { Bitmap bitmap = BitmapFactory.decodeFile(imagepath); bitmap = Utilidades.redimensionarBitmap( bitmap, Constantes.THUMB_SIZE, Constantes.THUMB_SIZE); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); imageByteArray = stream.toByteArray(); } Comment comment = new Comment( imageByteArray, jsoncomment.getString("msg"), jsoncomment.getString("username"), jsoncomment.getString("timestamp"), Utilidades.getDevId(getActivity()), jsoncomment.getString("id")); addCommentToList(comment); commentsadapter.notifyDataSetChanged(); etCommentTxt.setText(""); // borramos el edittext } else { Toast.makeText(getActivity(), mensaje, Toast.LENGTH_LONG).show(); } } catch (JSONException e) { e.printStackTrace(); } pDialog.dismiss(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.estadistica_view, container, false); int idEstadistica = this.mPageNumber; // Titulo y descripcion de estadistica TextView tituloEstadistica = (TextView) rootView.findViewById(R.id.TxtTituloEstadistica); TextView descEstadistica = (TextView) rootView.findViewById(R.id.TxtDescEstadistica); tituloEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getTitulo()); descEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getDescripcion()); rootView.addView( new EstadisticaViewLayout(Utilidades.getAppContext()) .getView(RelacionEstadisticas.getRelacion().get(idEstadistica))); // } // catch (Exception e) // { // Toast.makeText(Utilidades.getAppContext(), "error: " + e.getLocalizedMessage(), // Toast.LENGTH_LONG).show(); // Log.e("ERROR", e.getLocalizedMessage()); // } // Set the title view to show the page number. /*((TextView) rootView.findViewById(android.R.id.text1)).setText( getString(R.string.title_template_step, mPageNumber + 1));*/ return rootView; }
protected JSONObject doInBackground(String... args) { JSONObject json = new JSONObject(); ///////////////////////////////////////////////////// try { HttpUploader uploader = new HttpUploader( getActivity().getResources(), BuildConfig.DOMAIN + Constantes.LOAD_MESSAGES_FILE); uploader.añadirArgumento( "idevento", event.getId()); // le pasamos el codigo del evento del cual estamos mostrando el detalle uploader.añadirArgumento("thumb_width", Float.toString(Constantes.THUMB_SIZE)); uploader.añadirArgumento("thumb_height", Float.toString(Constantes.THUMB_SIZE)); uploader.añadirArgumento("timezoneoffset", Utilidades.getTimeZoneOffset(getActivity())); if ((args != null) && (args.length > 0)) { uploader.añadirArgumento("numerocomments", args[0]); } json = uploader.enviar(); } catch (ConnectionException e) { e.printStackTrace(); try { json.put(Constantes.JSON_MESSAGE, e.getMessage()); json.put(Constantes.JSON_SUCCESS, 0); } catch (JSONException e1) { e1.printStackTrace(); } } return json; }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; itemposition = info.position; if (itemposition > 0) itemposition--; // hay que restar 1 porque la lista tiene un header Comment comment = listaComments.get(itemposition); // Cuando pulsamos nos aparece como título la fecha y la hora para saber cual seleccionamos final int MAXLENGHT = 10; String txt = comment.getTxt(); if (txt.length() > MAXLENGHT) { // truncamos por la longitud maxima txt = txt.substring(0, MAXLENGHT) + " ..."; } menu.setHeaderTitle(comment.getUsername() + " : \"" + txt + "\""); byte[] img = comment.getImage(); if (img != null) { ByteArrayInputStream is = new ByteArrayInputStream(img); menu.setHeaderIcon(Drawable.createFromStream(is, "image")); } // si somos supervaca o somos los dueños del mensaje if ((BuildConfig.SUPERAPP) || (comment.getDevid() == Utilidades.getDevId(getActivity()))) { menu.add( FRAGMENT_GROUPID, R.id.action_borrar_comentario, 0, "Borrar comentario"); // podremos borrar } }
@Override public String decode(StringBuilder mensagemEmBinario) { StringBuilder array = new StringBuilder( mensagemEmBinario.subSequence( 0, mensagemEmBinario.length() - (polinomio.length() - 1))); return Utilidades.converteBinarioParaAscii(array); }
private static String addInfo(String mensaje) { StringBuffer sb = new StringBuffer(); sb.append(Utilidades.dateToString(new Date(), "dd/MM/yyyy HH:mm:ss")).append("\n"); sb.append(mensaje).append("\n"); return sb.toString(); }
private static void construyeListaFiltros() { int tmpInt; String tmpString; listaFiltros = new ArrayList<DatosFiltro>(); DatosFiltro fltAnio = new DatosFiltro("Año", "year"); Cursor cr = getAniosDiferentes(); while (cr.moveToNext()) { tmpInt = cr.getInt(0); tmpString = String.valueOf(tmpInt).trim(); fltAnio.addValor(tmpInt, tmpString); } cr.close(); listaFiltros.add(fltAnio); DatosFiltro fltMes = new DatosFiltro("Mes", "month"); cr = getMesesDiferentes(); while (cr.moveToNext()) { tmpInt = cr.getInt(0); tmpString = Utilidades.getNombreMes(tmpInt).trim(); fltMes.addValor(tmpInt, tmpString); } cr.close(); listaFiltros.add(fltMes); DatosFiltro fltTipoDeporte = new DatosFiltro("Tipo deporte", "sportType"); cr = getTiposDeporteDiferentes(); while (cr.moveToNext()) { tmpInt = cr.getInt(0); tmpString = Utilidades.getSportType(tmpInt).trim(); fltTipoDeporte.addValor(tmpInt, tmpString); } cr.close(); listaFiltros.add(fltTipoDeporte); }
@Override public String verificaErro(StringBuilder mensagemCodificada) { StringBuilder restoDivisao = Utilidades.retornaRestoDivisaoBits(new StringBuilder(mensagemCodificada), polinomio); int resultadoRestoDivisao = Integer.valueOf(restoDivisao.toString()); if (resultadoRestoDivisao != 0) { return "Mensagem transmitida com erro"; } else { return "Mensagem transmitida sem erro"; } }
public static void dialogo(String mensaje) { StringBuffer titulo = new StringBuffer(); StringBuffer mensajeDialogo = new StringBuffer(); titulo.append("Mensaje - "); titulo.append(Utilidades.dateToString(new Date(), "dd/MM/yyyy HH:mm:ss")); mensajeDialogo.append(mensaje); JOptionPane.showMessageDialog( null, mensajeDialogo, titulo.toString(), JOptionPane.QUESTION_MESSAGE); }
@Override public void run() { ventanaPrincipal.setEnabled(false); VentanaEspera ventanaEspera = new VentanaEspera(ventanaPrincipal); ventanaEspera.setVisible(true); uti.subirNuevoExcel(servi); ventanaEspera.dispose(); JOptionPane.showMessageDialog( ventanaPrincipal, "Servicio guardado correctamente", "Servicio", JOptionPane.INFORMATION_MESSAGE); ventanaPrincipal.setEnabled(true); ventanaPrincipal.requestFocus(); }
public MIDIReader(String filename) { this.filename = filename; try { this.recebedor = MidiSystem.getReceiver(); this.sequencia = MidiSystem.getSequence(new File(filename)); this.tempoProcessor = new MidiUtils.TempoCache(sequencia); this.player = MidiSystem.getSequencer(true); this.player.setSequence(sequencia); this.player.open(); this.interval = 0.5f; this.loadNotes(); this.duration = this.getRealDuration(); } catch (Exception ex) { Utilidades.alertar(ex.getMessage()); } }
@Override public void endElement(String uri, String nombreLocal, String nombreCualif) throws SAXException { String texto = Utilidades.quitaCosasRaras(cadena.toString()); try { texto = URLDecoder.decode(texto, "UTF8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (nombreLocal.equals("Series")) { lista.add(texto); } cadena.setLength(0); }
// Permite a execucao de uma nota do video public void tocar(float seconds, int corda) { if (!this.canPlay) { return; } corda = 6 - corda; try { for (MIDINote nota : this.notas) { if (nota.getSecond() == seconds && nota.getChord() == corda) { this.recebedor.send(nota.getShortMessage(), -1); return; } } } catch (Exception ex) { Utilidades.alertar("Erro na execucao do MIDI: " + ex.getMessage()); } }
protected JSONObject doInBackground(String... args) { JSONObject json = new JSONObject(); try { HttpUploader uploader = new HttpUploader( getActivity().getResources(), BuildConfig.DOMAIN + Constantes.LEER_EVENTOS_FILE); uploader.añadirArgumento( "_id", args[0]); // le pasamos el codigo del evento del cual estamos mostrando el detalle uploader.añadirArgumento("timezoneoffset", Utilidades.getTimeZoneOffset(getActivity())); json = uploader.enviar(); } catch (ConnectionException e) { e.printStackTrace(); try { json.put(Constantes.JSON_MESSAGE, e.getMessage()); json.put(Constantes.JSON_SUCCESS, 0); } catch (JSONException e1) { e1.printStackTrace(); } } return json; }
private void inicializar() { contenedor.getChildren().clear(); gridResultados = new Grid(); gridResultados.setMold("paging"); gridResultados.setPageSize(20); auxheadResultados = new Auxhead(); columnsResultados = new Columns(); Auxheader auxheader = new Auxheader(); auxheader.setAlign("center"); if (tipo_examen.equals(TIPO_PARACLINICO)) { auxheader.setLabel("REGISTROS DE RESULTADOS PARACLINICOS"); } else if (tipo_examen.equals(TIPO_VALORACION_OBSTETRICA)) { auxheader.setLabel("REGISTROS DE VALORACION OBSTETRICA"); } auxheader.setColspan(3); auxheadResultados.appendChild(auxheader); gridResultados.appendChild(auxheadResultados); Column column = new Column(""); if (tipo_examen.equals(TIPO_PARACLINICO)) { column.setLabel("Paraclinico"); } else if (tipo_examen.equals(TIPO_VALORACION_OBSTETRICA)) { column.setLabel("V. obstetrica"); } column.setWidth("170px"); columnsResultados.appendChild(column); column = new Column("Fecha"); column.setWidth("120px"); columnsResultados.appendChild(column); column = new Column("Resultado"); column.setWidth("120px"); columnsResultados.appendChild(column); gridResultados.appendChild(columnsResultados); Frozen frozen = new Frozen(); frozen.appendChild(new Div()); frozen.setColumns(3); gridResultados.appendChild(frozen); rowsResultado = new Rows(); Map<String, Object> parametros = new HashMap<String, Object>(); parametros.put("codigo_empresa", zkWindow.codigo_empresa); parametros.put("codigo_sucursal", zkWindow.codigo_sucursal); parametros.put("codigo_historia", pcodigo_historia); parametros.put("tipo_examen", tipo_examen); List<Phistorias_paraclinicos> listado = zkWindow.getServiceLocator().getPhistorias_paraclinicosService().listar(parametros); for (Phistorias_paraclinicos phistorias_paraclinicos : listado) { Row row_fila = new Row(); Cell celda = Utilidades.obtenerCell( phistorias_paraclinicos.getPexamenes_paraclinicos().getNombre(), Textbox.class, true, true); row_fila.appendChild(celda); celda = Utilidades.obtenerCell(null, Datebox.class, false, false); Datebox datebox_fecha = (Datebox) celda.getFirstChild(); datebox_fecha.setId( "datebox_fecha_" + tipo_examen + "_" + pcodigo_historia + "_" + phistorias_paraclinicos.getCodigo_examen()); row_fila.appendChild(celda); celda = Utilidades.obtenerCell("", Textbox.class, true, false); Textbox textbox_resultado = (Textbox) celda.getFirstChild(); textbox_resultado.setId( "textbox_resultado_" + tipo_examen + "_" + pcodigo_historia + "_" + phistorias_paraclinicos.getCodigo_examen()); final Popup popupResultados = generarPopupResultados( textbox_resultado, false, phistorias_paraclinicos.getPexamenes_paraclinicos()); textbox_resultado.setPopup(popupResultados); row_fila.appendChild(celda); row_fila.setValue(phistorias_paraclinicos); rowsResultado.appendChild(row_fila); } gridResultados.appendChild(rowsResultado); contenedor.appendChild(gridResultados); }