summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java9
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java34
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeAction.java52
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeActionChanges.java8
4 files changed, 52 insertions, 51 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java
index 4996decd2..be35badf0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java
@@ -148,7 +148,7 @@ public class SyncService extends Worker {
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
String json = prefs.getString(PREF_QUEUED_EPISODE_ACTIONS, "[]");
JSONArray queue = new JSONArray(json);
- queue.put(action.writeToJSONObject());
+ queue.put(action.writeToJsonObject());
prefs.edit().putString(PREF_QUEUED_EPISODE_ACTIONS, queue.toString()).apply();
} catch (JSONException e) {
e.printStackTrace();
@@ -217,7 +217,7 @@ public class SyncService extends Worker {
String json = prefs.getString(PREF_QUEUED_EPISODE_ACTIONS, "[]");
JSONArray queue = new JSONArray(json);
for (int i = 0; i < queue.length(); i++) {
- actions.add(EpisodeAction.readFromJSONObject(queue.getJSONObject(i)));
+ actions.add(EpisodeAction.readFromJsonObject(queue.getJSONObject(i)));
}
} catch (JSONException e) {
e.printStackTrace();
@@ -297,7 +297,7 @@ public class SyncService extends Worker {
synchronized (lock) {
UploadChangesResponse uploadResponse = syncServiceImpl
- .uploadSubscriptionChanges(queuedAddedFeeds, queuedRemovedFeeds);
+ .uploadSubscriptionChanges(queuedAddedFeeds, queuedRemovedFeeds);
getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit()
.putString(PREF_QUEUED_FEEDS_ADDED, "[]").apply();
getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit()
@@ -406,6 +406,9 @@ public class SyncService extends Worker {
case DELETE:
// NEVER EVER call DBWriter.deleteFeedMediaOfItem() here, leads to an infinite loop
break;
+ default:
+ Log.e(TAG, "Unknown action: " + action);
+ break;
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java
index 327232e1d..a35c961eb 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java
@@ -109,7 +109,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONArray jsonArray = new JSONArray(response);
- return readPodcastListFromJSONArray(jsonArray);
+ return readPodcastListFromJsonArray(jsonArray);
} catch (JSONException | MalformedURLException | URISyntaxException e) {
e.printStackTrace();
@@ -134,7 +134,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONArray jsonArray = new JSONArray(response);
- return readPodcastListFromJSONArray(jsonArray);
+ return readPodcastListFromJsonArray(jsonArray);
} catch (JSONException | MalformedURLException | URISyntaxException e) {
e.printStackTrace();
@@ -165,7 +165,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONArray jsonArray = new JSONArray(response);
- return readPodcastListFromJSONArray(jsonArray);
+ return readPodcastListFromJsonArray(jsonArray);
} catch (JSONException | MalformedURLException | URISyntaxException e) {
e.printStackTrace();
throw new GpodnetServiceException(e);
@@ -191,7 +191,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONArray jsonArray = new JSONArray(response);
- return readPodcastListFromJSONArray(jsonArray);
+ return readPodcastListFromJsonArray(jsonArray);
} catch (JSONException | MalformedURLException e) {
e.printStackTrace();
@@ -216,7 +216,7 @@ public class GpodnetService implements ISyncService {
Request.Builder request = new Request.Builder().url(url);
String response = executeRequest(request);
JSONArray devicesArray = new JSONArray(response);
- return readDeviceListFromJSONArray(devicesArray);
+ return readDeviceListFromJsonArray(devicesArray);
} catch (JSONException | MalformedURLException | URISyntaxException e) {
e.printStackTrace();
throw new GpodnetServiceException(e);
@@ -393,7 +393,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONObject changes = new JSONObject(response);
- return readSubscriptionChangesFromJSONObject(changes);
+ return readSubscriptionChangesFromJsonObject(changes);
} catch (URISyntaxException e) {
e.printStackTrace();
throw new IllegalStateException(e);
@@ -436,7 +436,7 @@ public class GpodnetService implements ISyncService {
final JSONArray list = new JSONArray();
for (int i = from; i < to; i++) {
EpisodeAction episodeAction = episodeActions.get(i);
- JSONObject obj = episodeAction.writeToJSONObject();
+ JSONObject obj = episodeAction.writeToJsonObject();
if (obj != null) {
obj.put("device", GpodnetPreferences.getDeviceID());
list.put(obj);
@@ -474,7 +474,7 @@ public class GpodnetService implements ISyncService {
String response = executeRequest(request);
JSONObject json = new JSONObject(response);
- return readEpisodeActionsFromJSONObject(json);
+ return readEpisodeActionsFromJsonObject(json);
} catch (URISyntaxException e) {
e.printStackTrace();
throw new IllegalStateException(e);
@@ -570,15 +570,15 @@ public class GpodnetService implements ISyncService {
}
}
- private List<GpodnetPodcast> readPodcastListFromJSONArray(@NonNull JSONArray array) throws JSONException {
+ private List<GpodnetPodcast> readPodcastListFromJsonArray(@NonNull JSONArray array) throws JSONException {
List<GpodnetPodcast> result = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {
- result.add(readPodcastFromJSONObject(array.getJSONObject(i)));
+ result.add(readPodcastFromJsonObject(array.getJSONObject(i)));
}
return result;
}
- private GpodnetPodcast readPodcastFromJSONObject(JSONObject object) throws JSONException {
+ private GpodnetPodcast readPodcastFromJsonObject(JSONObject object) throws JSONException {
String url = object.getString("url");
String title;
@@ -623,15 +623,15 @@ public class GpodnetService implements ISyncService {
return new GpodnetPodcast(url, title, description, subscribers, logoUrl, website, mygpoLink, author);
}
- private List<GpodnetDevice> readDeviceListFromJSONArray(@NonNull JSONArray array) throws JSONException {
+ private List<GpodnetDevice> readDeviceListFromJsonArray(@NonNull JSONArray array) throws JSONException {
List<GpodnetDevice> result = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {
- result.add(readDeviceFromJSONObject(array.getJSONObject(i)));
+ result.add(readDeviceFromJsonObject(array.getJSONObject(i)));
}
return result;
}
- private GpodnetDevice readDeviceFromJSONObject(JSONObject object) throws JSONException {
+ private GpodnetDevice readDeviceFromJsonObject(JSONObject object) throws JSONException {
String id = object.getString("id");
String caption = object.getString("caption");
String type = object.getString("type");
@@ -639,7 +639,7 @@ public class GpodnetService implements ISyncService {
return new GpodnetDevice(id, caption, type, subscriptions);
}
- private SubscriptionChanges readSubscriptionChangesFromJSONObject(@NonNull JSONObject object)
+ private SubscriptionChanges readSubscriptionChangesFromJsonObject(@NonNull JSONObject object)
throws JSONException {
List<String> added = new LinkedList<>();
@@ -664,7 +664,7 @@ public class GpodnetService implements ISyncService {
return new SubscriptionChanges(added, removed, timestamp);
}
- private EpisodeActionChanges readEpisodeActionsFromJSONObject(@NonNull JSONObject object)
+ private EpisodeActionChanges readEpisodeActionsFromJsonObject(@NonNull JSONObject object)
throws JSONException {
List<EpisodeAction> episodeActions = new ArrayList<>();
@@ -673,7 +673,7 @@ public class GpodnetService implements ISyncService {
JSONArray jsonActions = object.getJSONArray("actions");
for (int i = 0; i < jsonActions.length(); i++) {
JSONObject jsonAction = jsonActions.getJSONObject(i);
- EpisodeAction episodeAction = EpisodeAction.readFromJSONObject(jsonAction);
+ EpisodeAction episodeAction = EpisodeAction.readFromJsonObject(jsonAction);
if (episodeAction != null) {
episodeActions.add(episodeAction);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeAction.java b/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeAction.java
index a8eeedd03..6154ccc84 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeAction.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeAction.java
@@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.sync.model;
import android.text.TextUtils;
import android.util.Log;
+import androidx.core.util.ObjectsCompat;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.util.DateUtils;
import org.json.JSONException;
@@ -45,7 +46,7 @@ public class EpisodeAction {
* @param object JSON representation
* @return episode action object, or null if mandatory values are missing
*/
- public static EpisodeAction readFromJSONObject(JSONObject object) {
+ public static EpisodeAction readFromJsonObject(JSONObject object) {
String podcast = object.optString("podcast", null);
String episode = object.optString("episode", null);
String actionString = object.optString("action", null);
@@ -98,7 +99,7 @@ public class EpisodeAction {
}
/**
- * Returns the position (in seconds) at which the client started playback
+ * Returns the position (in seconds) at which the client started playback.
*
* @return start position (in seconds)
*/
@@ -107,7 +108,7 @@ public class EpisodeAction {
}
/**
- * Returns the position (in seconds) at which the client stopped playback
+ * Returns the position (in seconds) at which the client stopped playback.
*
* @return stop position (in seconds)
*/
@@ -126,21 +127,18 @@ public class EpisodeAction {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || !(o instanceof EpisodeAction)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof EpisodeAction)) {
+ return false;
+ }
EpisodeAction that = (EpisodeAction) o;
-
- if (started != that.started) return false;
- if (position != that.position) return false;
- if (total != that.total) return false;
- if (podcast != null ? !podcast.equals(that.podcast) : that.podcast != null) return false;
- if (episode != null ? !episode.equals(that.episode) : that.episode != null) return false;
- //if (deviceId != null ? !deviceId.equals(that.deviceId) : that.deviceId != null)
- // return false;
- if (action != that.action) return false;
- return !(timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null);
-
+ 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);
}
@Override
@@ -156,11 +154,11 @@ public class EpisodeAction {
}
/**
- * Returns a JSON object representation of this object
+ * Returns a JSON object representation of this object.
*
* @return JSON object representation, or null if the object is invalid
*/
- public JSONObject writeToJSONObject() {
+ public JSONObject writeToJsonObject() {
JSONObject obj = new JSONObject();
try {
obj.putOpt("podcast", this.podcast);
@@ -183,15 +181,15 @@ public class EpisodeAction {
@Override
public String toString() {
- return "EpisodeAction{" +
- "podcast='" + podcast + '\'' +
- ", episode='" + episode + '\'' +
- ", action=" + action +
- ", timestamp=" + timestamp +
- ", started=" + started +
- ", position=" + position +
- ", total=" + total +
- '}';
+ return "EpisodeAction{"
+ + "podcast='" + podcast + '\''
+ + ", episode='" + episode + '\''
+ + ", action=" + action
+ + ", timestamp=" + timestamp
+ + ", started=" + started
+ + ", position=" + position
+ + ", total=" + total
+ + '}';
}
public enum Action {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeActionChanges.java b/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeActionChanges.java
index 69c1b5280..77942ffa0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeActionChanges.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/sync/model/EpisodeActionChanges.java
@@ -25,9 +25,9 @@ public class EpisodeActionChanges {
@Override
public String toString() {
- return "EpisodeActionGetResponse{" +
- "episodeActions=" + episodeActions +
- ", timestamp=" + timestamp +
- '}';
+ return "EpisodeActionGetResponse{"
+ + "episodeActions=" + episodeActions
+ + ", timestamp=" + timestamp
+ + '}';
}
}