Skip to content

Commit

Permalink
minor changes to podcast downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
thasmin committed Jun 4, 2012
1 parent e0475cd commit 9d05b59
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/com/axelby/podax/PodcastDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,30 @@ public void download(int podcastId) {
cursor = _context.getContentResolver().query(PodcastProvider.QUEUE_URI, projection,
PodcastProvider.COLUMN_ID + " = ?",
new String[] { String.valueOf(podcastId) }, null);
while (cursor.moveToNext()) {
PodcastCursor podcast = new PodcastCursor(_context, cursor);
if (podcast.isDownloaded())
continue;
if (!cursor.moveToNext())
return;

File mediaFile = new File(podcast.getFilename());
PodcastCursor podcast = new PodcastCursor(_context, cursor);
if (podcast.isDownloaded())
return;

Log.d("Podax", "Downloading " + podcast.getTitle());
updateDownloadNotification(podcast, 0);
File mediaFile = new File(podcast.getFilename());

HttpURLConnection c = openConnection(podcast, mediaFile);
if (c == null)
continue;
Log.d("Podax", "Downloading " + podcast.getTitle());
updateDownloadNotification(podcast, 0);

if (!downloadFile(c, mediaFile))
continue;
HttpURLConnection c = openConnection(podcast, mediaFile);
if (c == null)
return;

if (mediaFile.length() == c.getContentLength())
podcast.determineDuration();
if (!downloadFile(c, mediaFile))
return;

removeDownloadNotification();
Log.d("Podax", "Done downloading " + podcast.getTitle());
}
if (mediaFile.length() == c.getContentLength())
podcast.determineDuration();

removeDownloadNotification();
Log.d("Podax", "Done downloading " + podcast.getTitle());
} finally {
if (cursor != null)
cursor.close();
Expand Down

0 comments on commit 9d05b59

Please sign in to comment.