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);
  }
Пример #2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    String filePickerResult = "";
    if (data != null && resultCode == RESULT_OK) {
      try {
        ContentResolver cr = getContentResolver();
        Uri uri = data.getData();
        Cursor cursor =
            GeckoApp.mAppContext
                .getContentResolver()
                .query(uri, new String[] {OpenableColumns.DISPLAY_NAME}, null, null, null);
        String name = null;
        if (cursor != null) {
          try {
            if (cursor.moveToNext()) {
              name = cursor.getString(0);
            }
          } finally {
            cursor.close();
          }
        }
        String fileName = "tmp_";
        String fileExt = null;
        int period;
        if (name == null || (period = name.lastIndexOf('.')) == -1) {
          String mimeType = cr.getType(uri);
          fileExt = "." + GeckoAppShell.getExtensionFromMimeType(mimeType);
        } else {
          fileExt = name.substring(period);
          fileName = name.substring(0, period);
        }
        File file = File.createTempFile(fileName, fileExt, sGREDir);

        FileOutputStream fos = new FileOutputStream(file);
        InputStream is = cr.openInputStream(uri);
        byte[] buf = new byte[4096];
        int len = is.read(buf);
        while (len != -1) {
          fos.write(buf, 0, len);
          len = is.read(buf);
        }
        fos.close();
        filePickerResult = file.getAbsolutePath();
      } catch (Exception e) {
        Log.e(LOG_FILE_NAME, "showing file picker", e);
      }
    }
    try {
      mFilePickerResult.put(filePickerResult);
    } catch (InterruptedException e) {
      Log.i(LOG_FILE_NAME, "error returning file picker result", e);
    }
  }