示例#1
0
 private long getFirstDownloadedId() {
   String[] projection = {
     PodcastProvider.COLUMN_ID, PodcastProvider.COLUMN_FILE_SIZE, PodcastProvider.COLUMN_MEDIA_URL,
   };
   Cursor c = query(QUEUE_URI, projection, null, null, null);
   long podcastId = -1;
   try {
     while (c.moveToNext()) {
       PodcastCursor podcast = new PodcastCursor(c);
       if (podcast.isDownloaded(getContext())) {
         podcastId = podcast.getId();
         break;
       }
     }
   } finally {
     c.close();
   }
   return podcastId;
 }
示例#2
0
  private String getNeedsDownloadIds() {
    SQLiteDatabase db = _dbAdapter.getReadableDatabase();
    SQLiteQueryBuilder queueBuilder = new SQLiteQueryBuilder();
    queueBuilder.setTables("podcasts");
    queueBuilder.appendWhere("queuePosition IS NOT NULL");
    Cursor queue =
        queueBuilder.query(
            db, new String[] {"_id, mediaUrl, fileSize"}, null, null, null, null, "queuePosition");
    String queueIds = "";

    if (queue != null) {
      while (queue.moveToNext()) {
        PodcastCursor podcast = new PodcastCursor(queue);
        if (!podcast.isDownloaded(getContext())) queueIds = queueIds + queue.getLong(0) + ",";
      }
      queue.close();
    }

    if (queueIds.length() > 0) queueIds = queueIds.substring(0, queueIds.length() - 1);
    return queueIds;
  }