summaryrefslogtreecommitdiff
path: root/model/src
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-03-02 09:50:24 +0100
committerGitHub <noreply@github.com>2024-03-02 09:50:24 +0100
commitee99ef934c131e5c75682c47129dd172a2203793 (patch)
treeb48aa5f68d199fc96d95f15fd41f98af1009bfcf /model/src
parentfa9dd8cb5a14ffb341d4af63535d4b9838bb0cdd (diff)
downloadAntennaPod-ee99ef934c131e5c75682c47129dd172a2203793.zip
Remove FeedComponent and FeedFile class (#6949)
We want to be more flexible in what we store for each type of item. Also rename misleading function (lastUpdate to lastModified)
Diffstat (limited to 'model/src')
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/download/DownloadResult.java15
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java16
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java104
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedComponent.java65
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedFile.java107
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java17
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java143
7 files changed, 188 insertions, 279 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/download/DownloadResult.java b/model/src/main/java/de/danoeh/antennapod/model/download/DownloadResult.java
index 66901cf65..8654db87e 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/download/DownloadResult.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/download/DownloadResult.java
@@ -4,8 +4,6 @@ import androidx.annotation.NonNull;
import java.util.Date;
-import de.danoeh.antennapod.model.feed.FeedFile;
-
/**
* Contains status attributes for one download
*/
@@ -42,18 +40,13 @@ public class DownloadResult {
private boolean successful;
private final Date completionDate;
- /**
- * Constructor for creating new completed downloads.
- */
- public DownloadResult(@NonNull FeedFile feedfile, String title, DownloadError reason, boolean successful,
- String reasonDetailed) {
- this(0, title, feedfile.getId(), feedfile.getTypeAsInt(), successful, reason, new Date(),
- reasonDetailed);
+ public DownloadResult(String title, long feedfileId, int feedfileType, boolean successful,
+ DownloadError reason, String reasonDetailed) {
+ this(0, title, feedfileId, feedfileType, successful, reason, new Date(), reasonDetailed);
}
public DownloadResult(long id, String title, long feedfileId, int feedfileType, boolean successful,
- DownloadError reason, Date completionDate,
- String reasonDetailed) {
+ DownloadError reason, Date completionDate, String reasonDetailed) {
this.id = id;
this.title = title;
this.feedfileId = feedfileId;
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java b/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java
index e55364dd9..3f4116f9c 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java
@@ -1,6 +1,7 @@
package de.danoeh.antennapod.model.feed;
-public class Chapter extends FeedComponent {
+public class Chapter {
+ private long id;
/** Defines starting point in milliseconds. */
private long start;
private String title;
@@ -62,12 +63,15 @@ public class Chapter extends FeedComponent {
}
@Override
- public String getHumanReadableIdentifier() {
- return title;
- }
-
- @Override
public String toString() {
return "ID3Chapter [title=" + getTitle() + ", start=" + getStart() + ", url=" + getLink() + "]";
}
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java
index 94a4776a5..0ea7dd1b7 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java
@@ -3,6 +3,7 @@ package de.danoeh.antennapod.model.feed;
import android.text.TextUtils;
import androidx.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Date;
@@ -13,7 +14,7 @@ import java.util.List;
*
* @author daniel
*/
-public class Feed extends FeedFile {
+public class Feed {
public static final int FEEDFILETYPE_FEED = 0;
public static final String TYPE_RSS2 = "rss";
@@ -21,6 +22,10 @@ public class Feed extends FeedFile {
public static final String PREFIX_LOCAL_FOLDER = "antennapod_local:";
public static final String PREFIX_GENERATIVE_COVER = "antennapod_generative_cover:";
+ private long id;
+ private String localFileUrl;
+ private String downloadUrl;
+ private boolean downloaded;
/**
* title as defined by the feed.
*/
@@ -51,7 +56,7 @@ public class Feed extends FeedFile {
/**
* String that identifies the last update (adopted from Last-Modified or ETag header).
*/
- private String lastUpdate;
+ private String lastModified;
private ArrayList<FeedFunding> fundingList;
/**
@@ -102,16 +107,18 @@ public class Feed extends FeedFile {
/**
* This constructor is used for restoring a feed from the database.
*/
- public Feed(long id, String lastUpdate, String title, String customTitle, String link,
+ public Feed(long id, String lastModified, String title, String customTitle, String link,
String description, String paymentLinks, String author, String language,
String type, String feedIdentifier, String imageUrl, String fileUrl,
String downloadUrl, boolean downloaded, boolean paged, String nextPageLink,
String filter, @Nullable SortOrder sortOrder, boolean lastUpdateFailed) {
- super(fileUrl, downloadUrl, downloaded);
+ this.localFileUrl = fileUrl;
+ this.downloadUrl = downloadUrl;
+ this.downloaded = downloaded;
this.id = id;
this.feedTitle = title;
this.customTitle = customTitle;
- this.lastUpdate = lastUpdate;
+ this.lastModified = lastModified;
this.link = link;
this.description = description;
this.fundingList = FeedFunding.extractPaymentLinks(paymentLinks);
@@ -135,11 +142,11 @@ public class Feed extends FeedFile {
/**
* This constructor is used for test purposes.
*/
- public Feed(long id, String lastUpdate, String title, String link, String description, String paymentLink,
+ public Feed(long id, String lastModified, String title, String link, String description, String paymentLink,
String author, String language, String type, String feedIdentifier, String imageUrl, String fileUrl,
String downloadUrl, boolean downloaded) {
- this(id, lastUpdate, title, null, link, description, paymentLink, author, language, type, feedIdentifier, imageUrl,
- fileUrl, downloadUrl, downloaded, false, null, null, null, false);
+ this(id, lastModified, title, null, link, description, paymentLink, author, language, type, feedIdentifier,
+ imageUrl, fileUrl, downloadUrl, downloaded, false, null, null, null, false);
}
/**
@@ -153,17 +160,19 @@ public class Feed extends FeedFile {
* This constructor is used for requesting a feed download (it must not be used for anything else!). It should NOT be
* used if the title of the feed is already known.
*/
- public Feed(String url, String lastUpdate) {
- super(null, url, false);
- this.lastUpdate = lastUpdate;
+ public Feed(String url, String lastModified) {
+ this.localFileUrl = null;
+ this.downloadUrl = url;
+ this.downloaded = false;
+ this.lastModified = lastModified;
}
/**
* This constructor is used for requesting a feed download (it must not be used for anything else!). It should be
* used if the title of the feed is already known.
*/
- public Feed(String url, String lastUpdate, String title) {
- this(url, lastUpdate);
+ public Feed(String url, String lastModified, String title) {
+ this(url, lastModified);
this.feedTitle = title;
}
@@ -171,8 +180,8 @@ public class Feed extends FeedFile {
* This constructor is used for requesting a feed download (it must not be used for anything else!). It should be
* used if the title of the feed is already known.
*/
- public Feed(String url, String lastUpdate, String title, String username, String password) {
- this(url, lastUpdate, title);
+ public Feed(String url, String lastModified, String title, String username, String password) {
+ this(url, lastModified, title);
preferences = new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF,
FeedPreferences.NewEpisodesAction.GLOBAL, username, password);
}
@@ -194,8 +203,8 @@ public class Feed extends FeedFile {
public String getIdentifyingValue() {
if (feedIdentifier != null && !feedIdentifier.isEmpty()) {
return feedIdentifier;
- } else if (download_url != null && !download_url.isEmpty()) {
- return download_url;
+ } else if (downloadUrl != null && !downloadUrl.isEmpty()) {
+ return downloadUrl;
} else if (feedTitle != null && !feedTitle.isEmpty()) {
return feedTitle;
} else {
@@ -203,14 +212,13 @@ public class Feed extends FeedFile {
}
}
- @Override
public String getHumanReadableIdentifier() {
if (!TextUtils.isEmpty(customTitle)) {
return customTitle;
} else if (!TextUtils.isEmpty(feedTitle)) {
return feedTitle;
} else {
- return download_url;
+ return downloadUrl;
}
}
@@ -249,8 +257,15 @@ public class Feed extends FeedFile {
}
}
+ /**
+ * Compare's this FeedFile's attribute values with another FeedFile's
+ * attribute values. This method will only compare attributes which were
+ * read from the feed.
+ *
+ * @return true if attribute values are different, false otherwise
+ */
public boolean compareWithOther(Feed other) {
- if (super.compareWithOther(other)) {
+ if (!StringUtils.equals(downloadUrl, other.downloadUrl)) {
return true;
}
if (other.imageUrl != null) {
@@ -313,11 +328,6 @@ public class Feed extends FeedFile {
return mostRecentItem;
}
- @Override
- public int getTypeAsInt() {
- return FEEDFILETYPE_FEED;
- }
-
public String getTitle() {
return !TextUtils.isEmpty(customTitle) ? customTitle : feedTitle;
}
@@ -375,12 +385,12 @@ public class Feed extends FeedFile {
this.items = list;
}
- public String getLastUpdate() {
- return lastUpdate;
+ public String getLastModified() {
+ return lastModified;
}
- public void setLastUpdate(String lastModified) {
- this.lastUpdate = lastModified;
+ public void setLastModified(String lastModified) {
+ this.lastModified = lastModified;
}
public String getFeedIdentifier() {
@@ -434,14 +444,44 @@ public class Feed extends FeedFile {
return preferences;
}
- @Override
public void setId(long id) {
- super.setId(id);
+ this.id = id;
if (preferences != null) {
preferences.setFeedID(id);
}
}
+ public long getId() {
+ return id;
+ }
+
+ public String getFile_url() {
+ return localFileUrl;
+ }
+
+ public void setFile_url(String fileUrl) {
+ this.localFileUrl = fileUrl;
+ if (fileUrl == null) {
+ downloaded = false;
+ }
+ }
+
+ public String getDownload_url() {
+ return downloadUrl;
+ }
+
+ public void setDownload_url(String downloadUrl) {
+ this.downloadUrl = downloadUrl;
+ }
+
+ public boolean isDownloaded() {
+ return downloaded;
+ }
+
+ public void setDownloaded(boolean downloaded) {
+ this.downloaded = downloaded;
+ }
+
public int getPageNr() {
return pageNr;
}
@@ -499,6 +539,6 @@ public class Feed extends FeedFile {
}
public boolean isLocalFeed() {
- return download_url.startsWith(PREFIX_LOCAL_FOLDER);
+ return downloadUrl.startsWith(PREFIX_LOCAL_FOLDER);
}
}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedComponent.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedComponent.java
deleted file mode 100644
index fa0ace3dc..000000000
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedComponent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package de.danoeh.antennapod.model.feed;
-
-/**
- * Represents every possible component of a feed
- *
- * @author daniel
- */
-public abstract class FeedComponent {
-
- long id;
-
- FeedComponent() {
- super();
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- /**
- * Update this FeedComponent's attributes with the attributes from another
- * FeedComponent. This method should only update attributes which where read from
- * the feed.
- */
- void updateFromOther(FeedComponent other) {
- }
-
- /**
- * Compare's this FeedComponent's attribute values with another FeedComponent's
- * attribute values. This method will only compare attributes which were
- * read from the feed.
- *
- * @return true if attribute values are different, false otherwise
- */
- boolean compareWithOther(FeedComponent other) {
- return false;
- }
-
-
- /**
- * Should return a non-null, human-readable String so that the item can be
- * identified by the user. Can be title, download-url, etc.
- */
- public abstract String getHumanReadableIdentifier();
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof FeedComponent)) return false;
-
- FeedComponent that = (FeedComponent) o;
-
- return id == that.id;
-
- }
-
- @Override
- public int hashCode() {
- return (int) (id ^ (id >>> 32));
- }
-}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedFile.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedFile.java
deleted file mode 100644
index c04fa0bb9..000000000
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedFile.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package de.danoeh.antennapod.model.feed;
-
-import android.text.TextUtils;
-
-import java.io.File;
-
-/**
- * Represents a component of a Feed that has to be downloaded
- */
-public abstract class FeedFile extends FeedComponent {
-
- String file_url;
- protected String download_url;
- boolean downloaded;
-
- /**
- * Creates a new FeedFile object.
- *
- * @param file_url The location of the FeedFile. If this is null, the downloaded-attribute
- * will automatically be set to false.
- * @param download_url The location where the FeedFile can be downloaded.
- * @param downloaded true if the FeedFile has been downloaded, false otherwise. This parameter
- * will automatically be interpreted as false if the file_url is null.
- */
- public FeedFile(String file_url, String download_url, boolean downloaded) {
- super();
- this.file_url = file_url;
- this.download_url = download_url;
- this.downloaded = (file_url != null) && downloaded;
- }
-
- public FeedFile() {
- this(null, null, false);
- }
-
- public abstract int getTypeAsInt();
-
- /**
- * Update this FeedFile's attributes with the attributes from another
- * FeedFile. This method should only update attributes which where read from
- * the feed.
- */
- void updateFromOther(FeedFile other) {
- super.updateFromOther(other);
- this.download_url = other.download_url;
- }
-
- /**
- * Compare's this FeedFile's attribute values with another FeedFile's
- * attribute values. This method will only compare attributes which were
- * read from the feed.
- *
- * @return true if attribute values are different, false otherwise
- */
- boolean compareWithOther(FeedFile other) {
- if (super.compareWithOther(other)) {
- return true;
- }
- if (!TextUtils.equals(download_url, other.download_url)) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns true if the file exists at file_url.
- */
- public boolean fileExists() {
- if (file_url == null) {
- return false;
- } else {
- File f = new File(file_url);
- return f.exists();
- }
- }
-
- public String getFile_url() {
- return file_url;
- }
-
- /**
- * Changes the file_url of this FeedFile. Setting this value to
- * null will also set the downloaded-attribute to false.
- */
- public void setFile_url(String file_url) {
- this.file_url = file_url;
- if (file_url == null) {
- downloaded = false;
- }
- }
-
- public String getDownload_url() {
- return download_url;
- }
-
- public void setDownload_url(String download_url) {
- this.download_url = download_url;
- }
-
- public boolean isDownloaded() {
- return downloaded;
- }
-
- public void setDownloaded(boolean downloaded) {
- this.downloaded = downloaded;
- }
-}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java
index be0760bdb..e078d755a 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java
@@ -17,13 +17,14 @@ import java.util.Set;
*
* @author daniel
*/
-public class FeedItem extends FeedComponent implements Serializable {
+public class FeedItem implements Serializable {
/** tag that indicates this item is in the queue */
public static final String TAG_QUEUE = "Queue";
/** tag that indicates this item is in favorites */
public static final String TAG_FAVORITE = "Favorite";
+ private long id;
/**
* The id/guid that can be found in the rss/atom feed. Might not be set.
*/
@@ -125,7 +126,6 @@ public class FeedItem extends FeedComponent implements Serializable {
}
public void updateFromOther(FeedItem other) {
- super.updateFromOther(other);
if (other.imageUrl != null) {
this.imageUrl = other.imageUrl;
}
@@ -163,6 +163,14 @@ public class FeedItem extends FeedComponent implements Serializable {
}
}
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
/**
* Returns the value that uniquely identifies this FeedItem. If the
* itemIdentifier attribute is not null, it will be returned. Else it will
@@ -350,11 +358,6 @@ public class FeedItem extends FeedComponent implements Serializable {
this.imageUrl = imageUrl;
}
- @Override
- public String getHumanReadableIdentifier() {
- return title;
- }
-
public boolean hasChapters() {
return hasChapters;
}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
index 991b5f3db..9d9c2246a 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
@@ -12,11 +12,13 @@ import de.danoeh.antennapod.model.MediaMetadataRetrieverCompat;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.model.playback.RemoteMedia;
+import org.apache.commons.lang3.StringUtils;
+import java.io.File;
import java.util.Date;
import java.util.List;
-public class FeedMedia extends FeedFile implements Playable {
+public class FeedMedia implements Playable {
public static final int FEEDFILETYPE_FEEDMEDIA = 2;
public static final int PLAYABLE_TYPE_FEEDMEDIA = 1;
public static final String FILENAME_PREFIX_EMBEDDED_COVER = "metadata-retriever:";
@@ -33,12 +35,16 @@ public class FeedMedia extends FeedFile implements Playable {
*/
private static final int CHECKED_ON_SIZE_BUT_UNKNOWN = Integer.MIN_VALUE;
+ private long id;
+ private String localFileUrl;
+ private String downloadUrl;
+ private boolean downloaded;
private int duration;
private int position; // Current position in file
private long lastPlayedTime; // Last time this media was played (in ms)
- private int played_duration; // How many ms of this file have been played
+ private int playedDuration; // How many ms of this file have been played
private long size; // File size in Byte
- private String mime_type;
+ private String mimeType;
@Nullable private volatile FeedItem item;
private Date playbackCompletionDate;
private int startPosition = -1;
@@ -50,47 +56,50 @@ public class FeedMedia extends FeedFile implements Playable {
/* Used for loading item when restoring from parcel. */
private long itemID;
- public FeedMedia(FeedItem i, String download_url, long size,
- String mime_type) {
- super(null, download_url, false);
+ public FeedMedia(FeedItem i, String downloadUrl, long size,
+ String mimeType) {
+ this.localFileUrl = null;
+ this.downloadUrl = downloadUrl;
+ this.downloaded = false;
this.item = i;
this.size = size;
- this.mime_type = mime_type;
+ this.mimeType = mimeType;
}
public FeedMedia(long id, FeedItem item, int duration, int position,
- long size, String mime_type, String file_url, String download_url,
- boolean downloaded, Date playbackCompletionDate, int played_duration,
+ long size, String mimeType, String localFileUrl, String downloadUrl,
+ boolean downloaded, Date playbackCompletionDate, int playedDuration,
long lastPlayedTime) {
- super(file_url, download_url, downloaded);
+ this.localFileUrl = localFileUrl;
+ this.downloadUrl = downloadUrl;
+ this.downloaded = downloaded;
this.id = id;
this.item = item;
this.duration = duration;
this.position = position;
- this.played_duration = played_duration;
- this.playedDurationWhenStarted = played_duration;
+ this.playedDuration = playedDuration;
+ this.playedDurationWhenStarted = playedDuration;
this.size = size;
- this.mime_type = mime_type;
+ this.mimeType = mimeType;
this.playbackCompletionDate = playbackCompletionDate == null
? null : (Date) playbackCompletionDate.clone();
this.lastPlayedTime = lastPlayedTime;
}
public FeedMedia(long id, FeedItem item, int duration, int position,
- long size, String mime_type, String file_url, String download_url,
- boolean downloaded, Date playbackCompletionDate, int played_duration,
- Boolean hasEmbeddedPicture, long lastPlayedTime) {
- this(id, item, duration, position, size, mime_type, file_url, download_url, downloaded,
- playbackCompletionDate, played_duration, lastPlayedTime);
+ long size, String mimeType, String localFileUrl, String downloadUrl,
+ boolean downloaded, Date playbackCompletionDate, int playedDuration,
+ Boolean hasEmbeddedPicture, long lastPlayedTime) {
+ this(id, item, duration, position, size, mimeType, localFileUrl, downloadUrl, downloaded,
+ playbackCompletionDate, playedDuration, lastPlayedTime);
this.hasEmbeddedPicture = hasEmbeddedPicture;
}
- @Override
public String getHumanReadableIdentifier() {
if (item != null && item.getTitle() != null) {
return item.getTitle();
} else {
- return download_url;
+ return downloadUrl;
}
}
@@ -120,28 +129,35 @@ public class FeedMedia extends FeedFile implements Playable {
* Uses mimetype to determine the type of media.
*/
public MediaType getMediaType() {
- return MediaType.fromMimeType(mime_type);
+ return MediaType.fromMimeType(mimeType);
}
public void updateFromOther(FeedMedia other) {
- super.updateFromOther(other);
+ this.downloadUrl = other.downloadUrl;
if (other.size > 0) {
size = other.size;
}
if (other.duration > 0 && duration <= 0) { // Do not overwrite duration that we measured after downloading
duration = other.duration;
}
- if (other.mime_type != null) {
- mime_type = other.mime_type;
+ if (other.mimeType != null) {
+ mimeType = other.mimeType;
}
}
+ /**
+ * Compare's this FeedFile's attribute values with another FeedFile's
+ * attribute values. This method will only compare attributes which were
+ * read from the feed.
+ *
+ * @return true if attribute values are different, false otherwise
+ */
public boolean compareWithOther(FeedMedia other) {
- if (super.compareWithOther(other)) {
+ if (!StringUtils.equals(downloadUrl, other.downloadUrl)) {
return true;
}
- if (other.mime_type != null) {
- if (mime_type == null || !mime_type.equals(other.mime_type)) {
+ if (other.mimeType != null) {
+ if (mimeType == null || !mimeType.equals(other.mimeType)) {
return true;
}
}
@@ -154,11 +170,6 @@ public class FeedMedia extends FeedFile implements Playable {
return false;
}
- @Override
- public int getTypeAsInt() {
- return FEEDFILETYPE_FEEDMEDIA;
- }
-
public int getDuration() {
return duration;
}
@@ -173,7 +184,7 @@ public class FeedMedia extends FeedFile implements Playable {
}
public int getPlayedDuration() {
- return played_duration;
+ return playedDuration;
}
public int getPlayedDurationWhenStarted() {
@@ -181,7 +192,7 @@ public class FeedMedia extends FeedFile implements Playable {
}
public void setPlayedDuration(int played_duration) {
- this.played_duration = played_duration;
+ this.playedDuration = played_duration;
}
public int getPosition() {
@@ -229,7 +240,7 @@ public class FeedMedia extends FeedFile implements Playable {
}
public String getMime_type() {
- return mime_type;
+ return mimeType;
}
@Nullable
@@ -283,18 +294,18 @@ public class FeedMedia extends FeedFile implements Playable {
dest.writeInt(duration);
dest.writeInt(position);
dest.writeLong(size);
- dest.writeString(mime_type);
- dest.writeString(file_url);
- dest.writeString(download_url);
+ dest.writeString(mimeType);
+ dest.writeString(localFileUrl);
+ dest.writeString(downloadUrl);
dest.writeByte((byte) ((downloaded) ? 1 : 0));
dest.writeLong((playbackCompletionDate != null) ? playbackCompletionDate.getTime() : 0);
- dest.writeInt(played_duration);
+ dest.writeInt(playedDuration);
dest.writeLong(lastPlayedTime);
}
@Override
public void writeToPreferences(Editor prefEditor) {
- if(item != null && item.getFeed() != null) {
+ if (item != null && item.getFeed() != null) {
prefEditor.putLong(PREF_FEED_ID, item.getFeed().getId());
} else {
prefEditor.putLong(PREF_FEED_ID, 0L);
@@ -345,12 +356,12 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public String getLocalMediaUrl() {
- return file_url;
+ return localFileUrl;
}
@Override
public String getStreamUrl() {
- return download_url;
+ return downloadUrl;
}
public int getStartPosition() {
@@ -371,7 +382,36 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public boolean localFileAvailable() {
- return isDownloaded() && file_url != null;
+ return isDownloaded() && localFileUrl != null;
+ }
+
+ public boolean fileExists() {
+ if (localFileUrl == null) {
+ return false;
+ } else {
+ File f = new File(localFileUrl);
+ return f.exists();
+ }
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getFile_url() {
+ return localFileUrl;
+ }
+
+ public boolean isDownloaded() {
+ return downloaded;
+ }
+
+ public String getDownload_url() {
+ return downloadUrl;
}
public long getItemId() {
@@ -381,14 +421,14 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public void onPlaybackStart() {
startPosition = Math.max(position, 0);
- playedDurationWhenStarted = played_duration;
+ playedDurationWhenStarted = playedDuration;
}
@Override
public void onPlaybackPause(Context context) {
if (position > startPosition) {
- played_duration = playedDurationWhenStarted + position - startPosition;
- playedDurationWhenStarted = played_duration;
+ playedDuration = playedDurationWhenStarted + position - startPosition;
+ playedDurationWhenStarted = playedDuration;
}
startPosition = position;
}
@@ -440,17 +480,18 @@ public class FeedMedia extends FeedFile implements Playable {
this.hasEmbeddedPicture = hasEmbeddedPicture;
}
- @Override
public void setDownloaded(boolean downloaded) {
- super.setDownloaded(downloaded);
- if(item != null && downloaded && item.isNew()) {
+ this.downloaded = downloaded;
+ if (item != null && downloaded && item.isNew()) {
item.setPlayed(false);
}
}
- @Override
public void setFile_url(String file_url) {
- super.setFile_url(file_url);
+ this.localFileUrl = file_url;
+ if (file_url == null) {
+ downloaded = false;
+ }
}
public void checkEmbeddedPicture() {