Download log now also supports DownloadStatus objects whose feedfile is
null
This commit is contained in:
parent
e25e3cab88
commit
b2aed41e8c
|
@ -48,11 +48,11 @@ public class DownloadLogAdapter extends ArrayAdapter<DownloadStatus> {
|
|||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
if (feedfile.getClass() == Feed.class) {
|
||||
if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
|
||||
holder.type.setText(R.string.download_type_feed);
|
||||
} else if (feedfile.getClass() == FeedMedia.class) {
|
||||
} else if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
|
||||
holder.type.setText(R.string.download_type_media);
|
||||
} else if (feedfile.getClass() == FeedImage.class) {
|
||||
} else if (status.getFeedfileType() == FeedImage.FEEDFILETYPE_FEEDIMAGE) {
|
||||
holder.type.setText(R.string.download_type_image);
|
||||
}
|
||||
if (status.getTitle() != null) {
|
||||
|
|
|
@ -2,7 +2,11 @@ package de.danoeh.antennapod.asynctask;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedFile;
|
||||
import de.danoeh.antennapod.feed.FeedImage;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.storage.PodDBAdapter;
|
||||
|
||||
/** Contains status attributes for one download */
|
||||
public class DownloadStatus {
|
||||
|
@ -33,9 +37,15 @@ public class DownloadStatus {
|
|||
protected String reasonDetailed;
|
||||
protected boolean successful;
|
||||
protected Date completionDate;
|
||||
protected FeedFile feedfile;
|
||||
/**
|
||||
* Is used to determine the type of the feedfile even if the feedfile does
|
||||
* not exist anymore. The value should be FEEDFILETYPE_FEED,
|
||||
* FEEDFILETYPE_FEEDIMAGE or FEEDFILETYPE_FEEDMEDIA
|
||||
*/
|
||||
protected int feedfileType;
|
||||
|
||||
// ------------------------------------ NOT STORED IN DB
|
||||
protected FeedFile feedfile;
|
||||
protected int progressPercent;
|
||||
protected long soFar;
|
||||
protected long size;
|
||||
|
@ -48,7 +58,7 @@ public class DownloadStatus {
|
|||
}
|
||||
|
||||
/** Constructor for restoring Download status entries from DB. */
|
||||
public DownloadStatus(long id, String title, FeedFile feedfile,
|
||||
public DownloadStatus(long id, String title, FeedFile feedfile, int feedfileType,
|
||||
boolean successful, int reason, Date completionDate,
|
||||
String reasonDetailed) {
|
||||
progressPercent = 100;
|
||||
|
@ -63,12 +73,13 @@ public class DownloadStatus {
|
|||
this.successful = successful;
|
||||
this.completionDate = completionDate;
|
||||
this.reasonDetailed = reasonDetailed;
|
||||
this.feedfileType = feedfileType;
|
||||
}
|
||||
|
||||
/** Constructor for creating new completed downloads. */
|
||||
public DownloadStatus(FeedFile feedfile, String title, int reason,
|
||||
boolean successful, String reasonDetailed) {
|
||||
this(0, title, feedfile, successful, reason, new Date(), reasonDetailed);
|
||||
this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason, new Date(), reasonDetailed);
|
||||
}
|
||||
|
||||
public FeedFile getFeedFile() {
|
||||
|
@ -111,10 +122,6 @@ public class DownloadStatus {
|
|||
return done;
|
||||
}
|
||||
|
||||
public void setFeedfile(FeedFile feedfile) {
|
||||
this.feedfile = feedfile;
|
||||
}
|
||||
|
||||
public void setProgressPercent(int progressPercent) {
|
||||
this.progressPercent = progressPercent;
|
||||
}
|
||||
|
@ -163,4 +170,8 @@ public class DownloadStatus {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public int getFeedfileType() {
|
||||
return feedfileType;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import de.danoeh.antennapod.PodcastApp;
|
|||
*
|
||||
*/
|
||||
public class Feed extends FeedFile {
|
||||
public static final int FEEDFILETYPE_FEED = 0;
|
||||
public static final String TYPE_RSS2 = "rss";
|
||||
public static final String TYPE_ATOM1 = "atom";
|
||||
|
||||
|
@ -143,6 +144,11 @@ public class Feed extends FeedFile {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTypeAsInt() {
|
||||
return FEEDFILETYPE_FEED;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.feed;
|
|||
|
||||
/** Represents a component of a Feed that has to be downloaded */
|
||||
public abstract class FeedFile extends FeedComponent {
|
||||
|
||||
protected String file_url;
|
||||
protected String download_url;
|
||||
protected boolean downloaded;
|
||||
|
@ -23,6 +24,8 @@ public abstract class FeedFile extends FeedComponent {
|
|||
*/
|
||||
public abstract String getHumanReadableIdentifier();
|
||||
|
||||
public abstract int getTypeAsInt();
|
||||
|
||||
public String getFile_url() {
|
||||
return file_url;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.danoeh.antennapod.feed;
|
||||
|
||||
public class FeedImage extends FeedFile {
|
||||
public static final int FEEDFILETYPE_FEEDIMAGE = 1;
|
||||
|
||||
protected String title;
|
||||
protected Feed feed;
|
||||
|
||||
|
@ -25,7 +27,12 @@ public class FeedImage extends FeedFile {
|
|||
return download_url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getTypeAsInt() {
|
||||
return FEEDFILETYPE_FEEDIMAGE;
|
||||
}
|
||||
|
||||
public FeedImage() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -954,17 +954,17 @@ public class FeedManager {
|
|||
|
||||
long feedfileId = logCursor
|
||||
.getLong(PodDBAdapter.KEY_FEEDFILE_INDEX);
|
||||
int feedfileType = logCursor
|
||||
.getInt(PodDBAdapter.KEY_FEEDFILETYPE_INDEX);
|
||||
if (feedfileId != 0) {
|
||||
int feedfileType = logCursor
|
||||
.getInt(PodDBAdapter.KEY_FEEDFILETYPE_INDEX);
|
||||
switch (feedfileType) {
|
||||
case PodDBAdapter.FEEDFILETYPE_FEED:
|
||||
case Feed.FEEDFILETYPE_FEED:
|
||||
feedfile = getFeed(feedfileId);
|
||||
break;
|
||||
case PodDBAdapter.FEEDFILETYPE_FEEDIMAGE:
|
||||
case FeedImage.FEEDFILETYPE_FEEDIMAGE:
|
||||
feedfile = getFeedImage(feedfileId);
|
||||
break;
|
||||
case PodDBAdapter.FEEDFILETYPE_FEEDMEDIA:
|
||||
case FeedMedia.FEEDFILETYPE_FEEDMEDIA:
|
||||
feedfile = getFeedMedia(feedfileId);
|
||||
}
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ public class FeedManager {
|
|||
Date completionDate = new Date(
|
||||
logCursor
|
||||
.getLong(PodDBAdapter.KEY_COMPLETION_DATE_INDEX));
|
||||
downloadLog.add(new DownloadStatus(id, title, feedfile, successful,
|
||||
downloadLog.add(new DownloadStatus(id, title, feedfile, feedfileType, successful,
|
||||
reason, completionDate, reasonDetailed));
|
||||
|
||||
} while (logCursor.moveToNext());
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package de.danoeh.antennapod.feed;
|
||||
|
||||
public class FeedMedia extends FeedFile {
|
||||
|
||||
public static final int FEEDFILETYPE_FEEDMEDIA = 2;
|
||||
|
||||
private int duration;
|
||||
private int position; // Current position in file
|
||||
private long size; // File size in Byte
|
||||
|
@ -42,6 +45,11 @@ public class FeedMedia extends FeedFile {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTypeAsInt() {
|
||||
return FEEDFILETYPE_FEEDMEDIA;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
|
|
@ -172,14 +172,6 @@ public class PodDBAdapter {
|
|||
+ " TEXT," + KEY_START + " INTEGER," + KEY_FEEDITEM + " INTEGER,"
|
||||
+ KEY_LINK + " TEXT)";
|
||||
|
||||
/**
|
||||
* Used for storing download status entries to determine the type of the
|
||||
* Feedfile.
|
||||
*/
|
||||
public static final int FEEDFILETYPE_FEED = 0;
|
||||
public static final int FEEDFILETYPE_FEEDIMAGE = 1;
|
||||
public static final int FEEDFILETYPE_FEEDMEDIA = 2;
|
||||
|
||||
private SQLiteDatabase db;
|
||||
private final Context context;
|
||||
private PodDBHelper helper;
|
||||
|
@ -377,11 +369,11 @@ public class PodDBAdapter {
|
|||
if (status.getFeedFile() != null) {
|
||||
values.put(KEY_FEEDFILE, status.getFeedFile().getId());
|
||||
if (status.getFeedFile().getClass() == Feed.class) {
|
||||
values.put(KEY_FEEDFILETYPE, FEEDFILETYPE_FEED);
|
||||
values.put(KEY_FEEDFILETYPE, Feed.FEEDFILETYPE_FEED);
|
||||
} else if (status.getFeedFile().getClass() == FeedImage.class) {
|
||||
values.put(KEY_FEEDFILETYPE, FEEDFILETYPE_FEEDIMAGE);
|
||||
values.put(KEY_FEEDFILETYPE, FeedImage.FEEDFILETYPE_FEEDIMAGE);
|
||||
} else if (status.getFeedFile().getClass() == FeedMedia.class) {
|
||||
values.put(KEY_FEEDFILETYPE, FEEDFILETYPE_FEEDMEDIA);
|
||||
values.put(KEY_FEEDFILETYPE, FeedMedia.FEEDFILETYPE_FEEDMEDIA);
|
||||
}
|
||||
}
|
||||
values.put(KEY_REASON, status.getReason());
|
||||
|
|
Loading…
Reference in New Issue