Exemplo n.º 1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
      LayoutInflater vi =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.note_row_layout, null);
    }
    Recording record = recordings.get(position);
    String name = record.getName();
    int time = record.getTime();
    if (name != null) {
      TextView mName = (TextView) v.findViewById(R.id.textTitle);
      if (mName != null) {
        mName.setText(name);
      }
    }
    TextView mTime = (TextView) v.findViewById(R.id.textNote);
    if (mTime != null) {

      SimpleDateFormat outFormat = new SimpleDateFormat("mm:ss");
      outFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

      Date d = new Date(time);
      String result = outFormat.format(d);

      mTime.setText(result);
    }
    return v;
  }
Exemplo n.º 2
0
  private void showRecordings() {
    ListView listView = (ListView) findViewById(R.id.audioRecorderListing);

    List<Recording> recordings = Recording.getRecordings();
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    for (Recording recording : recordings) {
      HashMap<String, String> item = new HashMap<String, String>();
      item.put("line1", "");
      item.put("line2", recording.getTimeString());
      item.put("amountHeard", recording.getDurationString());
      list.add(item);
    }
    /*
    		ArrayAdapter<HashMap<String, String>> notes = new ArrayAdapter<HashMap<String, String>>(this, R.layout.podcast_items, list);
    */
    SimpleAdapter notes =
        new SimpleAdapter(
            this,
            list,
            R.layout.podcast_items,
            new String[] {"line1", "line2", "amountHeard"},
            new int[] {R.id.firstLine, R.id.secondLine, R.id.amountHeard});

    listView.setAdapter(notes);
  }
Exemplo n.º 3
0
  @Override
  protected void getRelationTarget(RelationWs2 rel, IncludesWs2 inc) throws MBWS2Exception {

    super.getRelationTarget(rel, inc);

    /* Ws2 don't allow Artist Credits requests for areas
     * at the moment,so we have to complete the relations.
     * with target derived informations.
     *
     * Time consuming, but no other way. To avoid it, set
     * getIncludes().setArtistCredits(false) when asking for
     * relations.
     */

    if (!getIncludes().isArtistCredits()) return;

    if (inc.isRecordingRelations() && rel.getTargetType().equals(RelationWs2.TO_RECORDING)) {

      RecordingWs2 recWs2 = (RecordingWs2) rel.getTarget();

      if (recWs2.getArtistCredit() != null) return;

      Recording rec = new Recording();
      rec.setQueryWs(getQueryWs());

      rec.getIncludes().excludeAll();
      rec.getIncludes().setArtistCredits(true);

      recWs2 = rec.lookUp(recWs2);
      rel.setTarget(recWs2);
    } else if (inc.isReleaseRelations() && rel.getTargetType().equals(RelationWs2.TO_RELEASE)) {

      ReleaseWs2 relWs2 = (ReleaseWs2) rel.getTarget();

      if (relWs2.getArtistCredit() != null) return;

      Release rls = new Release();

      rls.setQueryWs(getQueryWs());

      rls.getIncludes().excludeAll();
      rls.getIncludes().setArtistCredits(true);

    } else if (inc.isReleaseGroupRelations()
        && rel.getTargetType().equals(RelationWs2.TO_RELEASE_GROUP)) {

      ReleaseGroupWs2 relWs2 = (ReleaseGroupWs2) rel.getTarget();

      if (relWs2.getArtistCredit() != null) return;

      ReleaseGroup rg = new ReleaseGroup();

      rg.setQueryWs(getQueryWs());

      rg.getIncludes().excludeAll();
      rg.getIncludes().setArtistCredits(true);
    }
  }
Exemplo n.º 4
0
 public Interview(Study study) {
   interview_time = new Date();
   study_id = study.getId();
   recordings = new ArrayList<Recording>(study.getPhrases().size());
   for (Phrase phrase : study.getPhrases()) {
     Recording recording = new Recording();
     recording.setPhrase_id(phrase.getId());
     recordings.add(recording);
   }
 }
  public Recording find(String id, int type) {
    try {
      Recording recording = new Recording();
      Statement st = conn.createStatement();
      String query =
          "SELECT * FROM recordings WHERE id = '" + id + "' AND filetype = '" + type + "'";
      ResultSet res = st.executeQuery(query);
      if (res.next()) {
        // return the found record as a whole
        recording.setTitle(res.getString("title"));
        recording.setDownloadURL(res.getString("downloadurl"));
        if (res.getBoolean("complete")) recording.setComplete();
        recording.setDescription(res.getString("description"));
        recording.setFilename(res.getString("filename"));
        recording.setFirstTried(new Date(res.getDate("firsttry").getTime()));
      } else {
        recording = new Recording();
      }
      res.close();
      st.close();
      res = null;
      st = null;

      return recording;
    } catch (SQLException sqlex) {
      LOG.error(
          "Java exception "
              + sqlex.getMessage()
              + " was thrown with with SQL message "
              + sqlex.getSQLState());
      return null;
    }
  }
Exemplo n.º 6
0
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {

    if (item.getItemId() == R.id.deleteAll) {
      Recording.deleteAll();
      showRecordings();
    }
    if (item.getItemId() == R.id.playAll) {}
    return super.onMenuItemSelected(featureId, item);
  }
Exemplo n.º 7
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   if (item.getTitle().equals("Play")) {
     Recording recording = Recording.getRecordings().get(info.position);
     recording.play();
   }
   if (item.getTitle().equals("Delete")) {
     Recording recording = Recording.getRecordings().get(info.position);
     recording.delete(this);
     showRecordings();
   }
   return true;
 }
Exemplo n.º 8
0
 /**
  * Gets the the number of recordings for the current prompt
  *
  * @return The number of recordings for the current prompt
  */
 public int getRecCount() {
   return recorded.getFileCount();
 }
Exemplo n.º 9
0
  /**
   * Get all of the recording's tags as a map(tagType, tagContent) (Used for fullText-indexing in
   * GoogleCloudService)
   *
   * @return Map of the recording's tags
   */
  public Map<String, String> getAllTagMapStrs() {
    // List<String> tagStrs = new ArrayList<String>();
    Map<String, String> tagStrs = new HashMap<String, String>();
    String respeakingId = "";

    if (!(fileType.equals(SOURCE_TYPE)
        || fileType.equals(SEGMENT_TYPE)
        || fileType.equals(RESPEAKING_TYPE)
        || fileType.equals(TRANSLATION_TYPE))) return tagStrs;
    if (!fileType.equals(SOURCE_TYPE)) respeakingId = getId().split("-")[3];

    List<String> selectedVerGroupOwners = new ArrayList<String>();
    List<File> groupDirList = new ArrayList<File>();

    File indexFile = new File(FileIO.getAppRootPath(), "index.json");
    JSONObject indices = null;
    try {
      indices = FileIO.readJSONObject(indexFile);
    } catch (IOException e1) {
      // TODO: How to deal with no index-file?
      Log.e(TAG, "getRespeakings(): error in reading index file");
      indices = new JSONObject();
    }

    // Collect directories where related respeakings exist form index file
    JSONArray verGroupOwnerList = (JSONArray) indices.get(getId());
    if (verGroupOwnerList == null) {
      // TODO: How to deal with no index-file?
      verGroupOwnerList = new JSONArray();
    }

    for (int i = 0; i < verGroupOwnerList.size(); i++) {
      String verGroupOwnerStr = (String) verGroupOwnerList.get(i);
      String[] splitVerGroupOwnerStr = verGroupOwnerStr.split("-");
      if (!splitVerGroupOwnerStr[0].matches(
          versionName)) // tag version needs to match recording version
      continue;

      File ownerDir = FileIO.getOwnerPath(splitVerGroupOwnerStr[0], splitVerGroupOwnerStr[2]);
      File groupDir = new File(Recording.getTagsPath(ownerDir), splitVerGroupOwnerStr[1]);

      if (groupDir.exists()) {
        selectedVerGroupOwners.add(verGroupOwnerStr);
        groupDirList.add(groupDir);
      }
    }

    // Process all the tag files
    for (int i = 0; i < groupDirList.size(); i++) {
      File groupDir = groupDirList.get(i);

      File[] tagFiles = groupDir.listFiles();
      for (File tagFile : tagFiles) {
        String tagTypeSuffix = "";
        String tagStr = "";
        String[] splitName = tagFile.getName().split("-");

        if (fileType.equals(SOURCE_TYPE) && splitName[2].equals(SOURCE_TYPE)) {
          tagTypeSuffix = splitName[3];
          tagStr = splitName[4];
        } else if (fileType.equals(splitName[2])
            && respeakingId.equals(splitName[3])) { // Respeaking/Interpret
          tagTypeSuffix = splitName[4];
          tagStr = splitName[5];
        } else continue;

        String val = tagStrs.get(tagTypeSuffix);
        if (val != null) {
          tagStrs.put(tagTypeSuffix, val + "|" + tagStr);
        } else {
          tagStrs.put(tagTypeSuffix, tagStr);
        }
        // tagStrs.add(tagTypeSuffix + "__" + tagStr);
        /*
        if(tagTypeSuffix.equals(Recording.SPEAKER_TAG_TYPE)) {

        } else if(tagTypeSuffix.equals(Recording.LANGUAGE_TAG_TYPE)) {

        } else if(tagTypeSuffix.equals(Recording.OLAC_TAG_TYPE)) {

        } else if(tagTypeSuffix.equals(Recording.CUSTOM_TAG_TYPE)) {

        }*/
      }
    }
    return tagStrs;
  }
Exemplo n.º 10
0
 public void recordCounter(ServerStatus serverStatus, String name, int counter) {
   if (shouldNotRecord(serverStatus)) return;
   lazyInitRecordings();
   recordings.add(Recording.counter(name, counter));
 }
Exemplo n.º 11
0
 // helper methods to optionally record timing information per message, useful for debugging or
 // benchmarking
 // not thread safe!
 public void recordTiming(ServerStatus serverStatus, String name, long elapsedNanos) {
   if (shouldNotRecord(serverStatus)) return;
   lazyInitRecordings();
   recordings.add(Recording.timing(name, elapsedNanos));
 }
  public void insert(Recording recording) throws SQLException {
    Statement st = conn.createStatement();
    StringBuffer sb = new StringBuffer();
    sb.append("INSERT INTO recordings VALUES('");
    sb.append(recording.getId());
    sb.append("', '");
    if (recording.getDownloadURL() == null) sb.append("");
    else sb.append(recording.getDownloadURL());
    sb.append("', '");
    if (recording.getTitle() == null) sb.append("");
    else sb.append(recording.getTitle());
    sb.append("', '");
    if (recording.getDescription() == null) sb.append("");
    else sb.append(recording.getDescription());
    sb.append("', '");
    if (recording.getFilename() == null) sb.append("");
    else sb.append(recording.getFilename());
    sb.append("', '");
    if (recording.getType() == 0) sb.append("");
    else sb.append(recording.getType());
    sb.append("', '");
    if (recording.getFirstTried() == null) sb.append("");
    else sb.append(new Timestamp(recording.getFirstTried().getTime()));
    sb.append("', ");
    if (!recording.isComplete()) sb.append("FALSE ");
    else sb.append("TRUE ");
    sb.append(")");
    LOG.debug(sb.toString());

    // execute the insert statement
    st.executeUpdate(sb.toString());
    st.close();
    st = null;

    conn.commit();
  }
  public void update(Recording recording) throws SQLException {
    Statement st = conn.createStatement();
    StringBuffer sb = new StringBuffer();
    sb.append("UPDATE recordings SET ");
    if (!(recording.getDownloadURL() == null)) {
      sb.append(" downloadurl = '");
      sb.append(recording.getDownloadURL());
      sb.append("' ");
    }
    if (!(recording.getTitle() == null)) {
      sb.append(", title = '");
      sb.append(recording.getTitle());
      sb.append("' ");
    }
    if (!(recording.getDescription() == null)) {
      sb.append(", description = '");
      sb.append(recording.getDescription());
      sb.append("' ");
    }
    if (!(recording.getFilename() == null)) {
      sb.append(", filename = '");
      sb.append(recording.getFilename());
      sb.append("' ");
    }
    if (!(recording.getFirstTried() == null)) {
      sb.append(", firsttry = '");
      sb.append(new java.sql.Timestamp(recording.getFirstTried().getTime()));
      sb.append("' ");
    }
    if (!recording.isComplete()) sb.append(", complete = FALSE ");
    else sb.append(", complete = TRUE ");
    sb.append("WHERE id = '");
    sb.append(recording.getId());
    sb.append("' AND filetype = '");
    sb.append(recording.getType());
    sb.append("'");

    LOG.debug(sb.toString());
    st.execute(sb.toString());
    st.close();
    st = null;

    conn.commit();
  }
 public void update(List<Recording> recordings) throws SQLException {
   for (Recording recording : recordings) {
     if (recording.isComplete()) this.update(recording);
   }
 }