summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorthrillfall <thrillfall@users.noreply.github.com>2021-08-20 20:17:23 +0200
committerGitHub <noreply@github.com>2021-08-20 20:17:23 +0200
commitdb391867608fa37f6568eca02678b3b376e52fa8 (patch)
tree74210432fbb3426c3243687de580094d9fc513ff /net
parent7ebaa9f619e004c8f2231bce1d170007c9de1544 (diff)
downloadAntennaPod-db391867608fa37f6568eca02678b3b376e52fa8.zip
Identify episodes by guid (#5326)
Diffstat (limited to 'net')
-rw-r--r--net/sync/model/src/main/java/de/danoeh/antennapod/net/sync/model/EpisodeAction.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/net/sync/model/src/main/java/de/danoeh/antennapod/net/sync/model/EpisodeAction.java b/net/sync/model/src/main/java/de/danoeh/antennapod/net/sync/model/EpisodeAction.java
index 1aae5c811..cf4744c3e 100644
--- a/net/sync/model/src/main/java/de/danoeh/antennapod/net/sync/model/EpisodeAction.java
+++ b/net/sync/model/src/main/java/de/danoeh/antennapod/net/sync/model/EpisodeAction.java
@@ -25,6 +25,7 @@ public class EpisodeAction {
private final String podcast;
private final String episode;
+ private final String guid;
private final Action action;
private final Date timestamp;
private final int started;
@@ -34,6 +35,7 @@ public class EpisodeAction {
private EpisodeAction(Builder builder) {
this.podcast = builder.podcast;
this.episode = builder.episode;
+ this.guid = builder.guid;
this.action = builder.action;
this.timestamp = builder.timestamp;
this.started = builder.started;
@@ -72,6 +74,10 @@ public class EpisodeAction {
e.printStackTrace();
}
}
+ String guid = object.optString("guid", null);
+ if (!TextUtils.isEmpty(guid)) {
+ builder.guid(guid);
+ }
if (action == EpisodeAction.Action.PLAY) {
int started = object.optInt("started", -1);
int position = object.optInt("position", -1);
@@ -94,6 +100,10 @@ public class EpisodeAction {
return this.episode;
}
+ public String getGuid() {
+ return this.guid;
+ }
+
public Action getAction() {
return this.action;
}
@@ -143,16 +153,21 @@ public class EpisodeAction {
}
EpisodeAction that = (EpisodeAction) o;
- return started == that.started && position == that.position && total == that.total && action != that.action
+ return started == that.started
+ && position == that.position
+ && total == that.total
+ && action != that.action
&& ObjectsCompat.equals(podcast, that.podcast)
&& ObjectsCompat.equals(episode, that.episode)
- && ObjectsCompat.equals(timestamp, that.timestamp);
+ && ObjectsCompat.equals(timestamp, that.timestamp)
+ && ObjectsCompat.equals(guid, that.guid);
}
@Override
public int hashCode() {
int result = podcast != null ? podcast.hashCode() : 0;
result = 31 * result + (episode != null ? episode.hashCode() : 0);
+ result = 31 * result + (guid != null ? guid.hashCode() : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
result = 31 * result + started;
@@ -171,6 +186,7 @@ public class EpisodeAction {
try {
obj.putOpt("podcast", this.podcast);
obj.putOpt("episode", this.episode);
+ obj.putOpt("guid", this.guid);
obj.put("action", this.getActionString());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
@@ -193,6 +209,7 @@ public class EpisodeAction {
return "EpisodeAction{"
+ "podcast='" + podcast + '\''
+ ", episode='" + episode + '\''
+ + ", guid='" + guid + '\''
+ ", action=" + action
+ ", timestamp=" + timestamp
+ ", started=" + started
@@ -217,6 +234,7 @@ public class EpisodeAction {
private int started = -1;
private int position = -1;
private int total = -1;
+ private String guid;
public Builder(FeedItem item, Action action) {
this(item.getFeed().getDownload_url(), item.getMedia().getDownload_url(), action);
@@ -233,6 +251,11 @@ public class EpisodeAction {
return this;
}
+ public Builder guid(String guid) {
+ this.guid = guid;
+ return this;
+ }
+
public Builder currentTimestamp() {
return timestamp(new Date());
}