summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Hennen <TomHennen@users.noreply.github.com>2015-12-02 17:45:48 -0500
committerTom Hennen <TomHennen@users.noreply.github.com>2015-12-02 17:45:48 -0500
commitf3758e33c28eae203bd6cfd0fee8cf3fb9c6b2d5 (patch)
tree1650e0984c461619e1654d72afb35e482b28b039 /core
parente6cfc71ebb08ce2ad26df3631a5a9ebcc5742a30 (diff)
parent2c992d83386708742708993deb4f158e3f4d136c (diff)
downloadAntennaPod-f3758e33c28eae203bd6cfd0fee8cf3fb9c6b2d5.zip
Merge pull request #1440 from mfietz/issue/1439-stupid-MIUI
Fix MIUI crash
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java3
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetService.java105
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetDevice.java8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeAction.java69
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeActionGetResponse.java14
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetPodcast.java15
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetSubscriptionChange.java8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetTag.java8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/receiver/AlarmUpdateReceiver.java7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java22
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java20
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java13
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java17
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java15
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java24
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceTaskManager.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java18
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java12
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java46
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java10
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java10
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/syndication/FeedDiscoverer.java7
30 files changed, 254 insertions, 274 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java
index 93b584677..ac032fcc0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java
@@ -6,11 +6,11 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.AsyncTask;
+import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.widget.Toast;
-import org.apache.commons.lang3.Validate;
import org.shredzone.flattr4j.exception.FlattrException;
import java.util.LinkedList;
@@ -63,8 +63,7 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke
*
* @param context A context for accessing the database and posting notifications. Must not be null.
*/
- public FlattrClickWorker(Context context) {
- Validate.notNull(context);
+ public FlattrClickWorker(@NonNull Context context) {
this.context = context.getApplicationContext();
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java b/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
index 3425e8a8e..7ccb742fb 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
@@ -3,8 +3,6 @@ package de.danoeh.antennapod.core.feed;
import android.os.Handler;
import android.util.Log;
-import org.apache.commons.lang3.Validate;
-
import java.util.AbstractQueue;
import java.util.Observable;
import java.util.Observer;
@@ -84,7 +82,6 @@ public class EventDistributor extends Observable {
@Override
public void addObserver(Observer observer) {
super.addObserver(observer);
- Validate.isInstanceOf(EventListener.class, observer);
}
public void sendUnreadItemsUpdateBroadcast() {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
index 2acb7108d..0de046fe5 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
@@ -4,8 +4,7 @@ import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.support.annotation.Nullable;
-
-import org.apache.commons.lang3.StringUtils;
+import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Date;
@@ -367,7 +366,7 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
if (other.isPaged() && !this.isPaged()) {
return true;
}
- if (!StringUtils.equals(other.getNextPageLink(), this.getNextPageLink())) {
+ if (!TextUtils.equals(other.getNextPageLink(), this.getNextPageLink())) {
return true;
}
return false;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java
index c1d21552e..d3d5dd0a1 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java
@@ -1,8 +1,6 @@
package de.danoeh.antennapod.core.feed;
-import android.content.Context;
-
-import org.apache.commons.lang3.StringUtils;
+import android.text.TextUtils;
import java.util.ArrayList;
import java.util.List;
@@ -22,7 +20,7 @@ public class FeedItemFilter {
private boolean hideNotDownloaded = false;
public FeedItemFilter(String properties) {
- this(StringUtils.split(properties, ','));
+ this(TextUtils.split(",", properties));
}
public FeedItemFilter(String[] properties) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java
index eb28a3185..ed568a6e5 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java
@@ -2,8 +2,7 @@ package de.danoeh.antennapod.core.feed;
import android.content.Context;
import android.database.Cursor;
-
-import org.apache.commons.lang3.StringUtils;
+import android.text.TextUtils;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBWriter;
@@ -60,10 +59,10 @@ public class FeedPreferences {
public boolean compareWithOther(FeedPreferences other) {
if (other == null)
return true;
- if (!StringUtils.equals(username, other.username)) {
+ if (!TextUtils.equals(username, other.username)) {
return true;
}
- if (!StringUtils.equals(password, other.password)) {
+ if (!TextUtils.equals(password, other.password)) {
return true;
}
return false;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetService.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetService.java
index d8e07085d..d2a13f768 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetService.java
@@ -1,5 +1,7 @@
package de.danoeh.antennapod.core.gpoddernet;
+import android.support.annotation.NonNull;
+
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
@@ -8,7 +10,6 @@ import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
-import org.apache.commons.lang3.Validate;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
@@ -101,10 +102,9 @@ public class GpodnetService {
*
* @throws IllegalArgumentException if tag is null
*/
- public List<GpodnetPodcast> getPodcastsForTag(GpodnetTag tag, int count)
+ public List<GpodnetPodcast> getPodcastsForTag(@NonNull GpodnetTag tag,
+ int count)
throws GpodnetServiceException {
- Validate.notNull(tag);
-
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
"/api/2/tag/%s/%d.json", tag.getTag(), count), null).toURL();
@@ -128,7 +128,9 @@ public class GpodnetService {
*/
public List<GpodnetPodcast> getPodcastToplist(int count)
throws GpodnetServiceException {
- Validate.isTrue(count >= 1 && count <= 100, "Count must be in range 1..100");
+ if(count < 1 || count > 100) {
+ throw new IllegalArgumentException("Count must be in range 1..100");
+ }
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
@@ -158,7 +160,9 @@ public class GpodnetService {
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
public List<GpodnetPodcast> getSuggestions(int count) throws GpodnetServiceException {
- Validate.isTrue(count >= 1 && count <= 100, "Count must be in range 1..100");
+ if(count < 1 || count > 100) {
+ throw new IllegalArgumentException("Count must be in range 1..100");
+ }
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
@@ -215,10 +219,8 @@ public class GpodnetService {
* @throws IllegalArgumentException If username is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public List<GpodnetDevice> getDevices(String username)
+ public List<GpodnetDevice> getDevices(@NonNull String username)
throws GpodnetServiceException {
- Validate.notNull(username);
-
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
"/api/2/devices/%s.json", username), null).toURL();
@@ -243,12 +245,11 @@ public class GpodnetService {
* @throws IllegalArgumentException If username or deviceId is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public void configureDevice(String username, String deviceId,
- String caption, GpodnetDevice.DeviceType type)
+ public void configureDevice(@NonNull String username,
+ @NonNull String deviceId,
+ String caption,
+ GpodnetDevice.DeviceType type)
throws GpodnetServiceException {
- Validate.notNull(username);
- Validate.notNull(deviceId);
-
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
"/api/2/devices/%s/%s.json", username, deviceId), null).toURL();
@@ -286,11 +287,9 @@ public class GpodnetService {
* @throws IllegalArgumentException If username or deviceId is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public String getSubscriptionsOfDevice(String username, String deviceId)
+ public String getSubscriptionsOfDevice(@NonNull String username,
+ @NonNull String deviceId)
throws GpodnetServiceException {
- Validate.notNull(username);
- Validate.notNull(deviceId);
-
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
"/subscriptions/%s/%s.opml", username, deviceId), null).toURL();
@@ -313,9 +312,8 @@ public class GpodnetService {
* @throws IllegalArgumentException If username is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public String getSubscriptionsOfUser(String username)
+ public String getSubscriptionsOfUser(@NonNull String username)
throws GpodnetServiceException {
- Validate.notNull(username);
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
@@ -342,12 +340,11 @@ public class GpodnetService {
* @throws IllegalArgumentException If username, deviceId or subscriptions is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public void uploadSubscriptions(String username, String deviceId,
- List<String> subscriptions) throws GpodnetServiceException {
- if (username == null || deviceId == null || subscriptions == null) {
- throw new IllegalArgumentException(
- "Username, device ID and subscriptions must not be null");
- }
+ public void uploadSubscriptions(@NonNull String username,
+ @NonNull String deviceId,
+ @NonNull List<String> subscriptions)
+ throws GpodnetServiceException {
+
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
"/subscriptions/%s/%s.txt", username, deviceId), null).toURL();
@@ -363,6 +360,7 @@ public class GpodnetService {
e.printStackTrace();
throw new GpodnetServiceException(e);
}
+
}
/**
@@ -381,12 +379,11 @@ public class GpodnetService {
* @throws de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException if added or removed contain duplicates or if there
* is an authentication error.
*/
- public GpodnetUploadChangesResponse uploadChanges(String username, String deviceId, Collection<String> added,
- Collection<String> removed) throws GpodnetServiceException {
- Validate.notNull(username);
- Validate.notNull(deviceId);
- Validate.notNull(added);
- Validate.notNull(removed);
+ public GpodnetUploadChangesResponse uploadChanges(@NonNull String username,
+ @NonNull String deviceId,
+ @NonNull Collection<String> added,
+ @NonNull Collection<String> removed)
+ throws GpodnetServiceException {
try {
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
@@ -422,10 +419,9 @@ public class GpodnetService {
* @throws IllegalArgumentException If username or deviceId is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
- public GpodnetSubscriptionChange getSubscriptionChanges(String username,
- String deviceId, long timestamp) throws GpodnetServiceException {
- Validate.notNull(username);
- Validate.notNull(deviceId);
+ public GpodnetSubscriptionChange getSubscriptionChanges(@NonNull String username,
+ @NonNull String deviceId,
+ long timestamp) throws GpodnetServiceException {
String params = String.format("since=%d", timestamp);
String path = String.format("/api/2/subscriptions/%s/%s.json",
@@ -460,11 +456,9 @@ public class GpodnetService {
* @throws de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException if added or removed contain duplicates or if there
* is an authentication error.
*/
- public GpodnetEpisodeActionPostResponse uploadEpisodeActions(Collection<GpodnetEpisodeAction> episodeActions)
+ public GpodnetEpisodeActionPostResponse uploadEpisodeActions(@NonNull Collection<GpodnetEpisodeAction> episodeActions)
throws GpodnetServiceException {
- Validate.notNull(episodeActions);
-
String username = GpodnetPreferences.getUsername();
try {
@@ -533,11 +527,9 @@ public class GpodnetService {
*
* @throws IllegalArgumentException If username or password is null.
*/
- public void authenticate(String username, String password)
+ public void authenticate(@NonNull String username,
+ @NonNull String password)
throws GpodnetServiceException {
- Validate.notNull(username);
- Validate.notNull(password);
-
URL url;
try {
url = new URI(BASE_SCHEME, BASE_HOST, String.format(
@@ -564,10 +556,8 @@ public class GpodnetService {
}.start();
}
- private String executeRequest(Request.Builder requestB)
+ private String executeRequest(@NonNull Request.Builder requestB)
throws GpodnetServiceException {
- Validate.notNull(requestB);
-
Request request = requestB.header("User-Agent", ClientConfig.USER_AGENT).build();
String responseString = null;
Response response = null;
@@ -631,10 +621,8 @@ public class GpodnetService {
return result;
}
- private String getStringFromResponseBody(ResponseBody body)
+ private String getStringFromResponseBody(@NonNull ResponseBody body)
throws GpodnetServiceException {
- Validate.notNull(body);
-
ByteArrayOutputStream outputStream;
int contentLength = 0;
try {
@@ -661,9 +649,8 @@ public class GpodnetService {
return outputStream.toString();
}
- private void checkStatusCode(Response response)
+ private void checkStatusCode(@NonNull Response response)
throws GpodnetServiceException {
- Validate.notNull(response);
int responseCode = response.code();
if (responseCode != HttpStatus.SC_OK) {
if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
@@ -675,17 +662,14 @@ public class GpodnetService {
}
}
- private List<GpodnetPodcast> readPodcastListFromJSONArray(JSONArray array)
+ private List<GpodnetPodcast> readPodcastListFromJSONArray(@NonNull JSONArray array)
throws JSONException {
- Validate.notNull(array);
-
List<GpodnetPodcast> result = new ArrayList<GpodnetPodcast>(
array.length());
for (int i = 0; i < array.length(); i++) {
result.add(readPodcastFromJSONObject(array.getJSONObject(i)));
}
return result;
-
}
private GpodnetPodcast readPodcastFromJSONObject(JSONObject object)
@@ -730,10 +714,8 @@ public class GpodnetService {
logoUrl, website, mygpoLink);
}
- private List<GpodnetDevice> readDeviceListFromJSONArray(JSONArray array)
+ private List<GpodnetDevice> readDeviceListFromJSONArray(@NonNull JSONArray array)
throws JSONException {
- Validate.notNull(array);
-
List<GpodnetDevice> result = new ArrayList<GpodnetDevice>(
array.length());
for (int i = 0; i < array.length(); i++) {
@@ -752,8 +734,7 @@ public class GpodnetService {
}
private GpodnetSubscriptionChange readSubscriptionChangesFromJSONObject(
- JSONObject object) throws JSONException {
- Validate.notNull(object);
+ @NonNull JSONObject object) throws JSONException {
List<String> added = new LinkedList<String>();
JSONArray jsonAdded = object.getJSONArray("add");
@@ -772,8 +753,7 @@ public class GpodnetService {
}
private GpodnetEpisodeActionGetResponse readEpisodeActionsFromJSONObject(
- JSONObject object) throws JSONException {
- Validate.notNull(object);
+ @NonNull JSONObject object) throws JSONException {
List<GpodnetEpisodeAction> episodeActions = new ArrayList<GpodnetEpisodeAction>();
@@ -789,5 +769,4 @@ public class GpodnetService {
return new GpodnetEpisodeActionGetResponse(episodeActions, timestamp);
}
-
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetDevice.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetDevice.java
index 4885a243a..2d49c170a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetDevice.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetDevice.java
@@ -1,6 +1,6 @@
package de.danoeh.antennapod.core.gpoddernet.model;
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
public class GpodnetDevice {
@@ -9,10 +9,10 @@ public class GpodnetDevice {
private DeviceType type;
private int subscriptions;
- public GpodnetDevice(String id, String caption, String type,
+ public GpodnetDevice(@NonNull String id,
+ String caption,
+ String type,
int subscriptions) {
- Validate.notNull(id);
-
this.id = id;
this.caption = caption;
this.type = DeviceType.fromString(type);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeAction.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeAction.java
index efe39485e..2d174a6bc 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeAction.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeAction.java
@@ -1,13 +1,9 @@
package de.danoeh.antennapod.core.gpoddernet.model;
+import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
import org.json.JSONException;
import org.json.JSONObject;
@@ -90,7 +86,7 @@ public class GpodnetEpisodeAction {
String podcast = object.optString("podcast", null);
String episode = object.optString("episode", null);
String actionString = object.optString("action", null);
- if(StringUtils.isEmpty(podcast) || StringUtils.isEmpty(episode) || StringUtils.isEmpty(actionString)) {
+ if(TextUtils.isEmpty(podcast) || TextUtils.isEmpty(episode) || TextUtils.isEmpty(actionString)) {
return null;
}
GpodnetEpisodeAction.Action action;
@@ -103,7 +99,7 @@ public class GpodnetEpisodeAction {
GpodnetEpisodeAction.Builder builder = new GpodnetEpisodeAction.Builder(podcast, episode, action)
.deviceId(deviceId);
String utcTimestamp = object.optString("timestamp", null);
- if(StringUtils.isNotEmpty(utcTimestamp)) {
+ if(!TextUtils.isEmpty(utcTimestamp)) {
builder.timestamp(DateUtils.parse(utcTimestamp));
}
if(action == GpodnetEpisodeAction.Action.PLAY) {
@@ -173,34 +169,34 @@ public class GpodnetEpisodeAction {
@Override
public boolean equals(Object o) {
- if(o == null) return false;
- if(this == o) return true;
- if(this.getClass() != o.getClass()) return false;
- GpodnetEpisodeAction that = (GpodnetEpisodeAction)o;
- return new EqualsBuilder()
- .append(this.podcast, that.podcast)
- .append(this.episode, that.episode)
- .append(this.deviceId, that.deviceId)
- .append(this.action, that.action)
- .append(this.timestamp, that.timestamp)
- .append(this.started, that.started)
- .append(this.position, that.position)
- .append(this.total, that.total)
- .isEquals();
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ GpodnetEpisodeAction that = (GpodnetEpisodeAction) 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);
+
}
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(this.podcast)
- .append(this.episode)
- .append(this.deviceId)
- .append(this.action)
- .append(this.timestamp)
- .append(this.started)
- .append(this.position)
- .append(this.total)
- .toHashCode();
+ int result = podcast != null ? podcast.hashCode() : 0;
+ result = 31 * result + (episode != null ? episode.hashCode() : 0);
+ result = 31 * result + (deviceId != null ? deviceId.hashCode() : 0);
+ result = 31 * result + (action != null ? action.hashCode() : 0);
+ result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
+ result = 31 * result + started;
+ result = 31 * result + position;
+ result = 31 * result + total;
+ return result;
}
public String writeToString() {
@@ -245,7 +241,16 @@ public class GpodnetEpisodeAction {
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ return "GpodnetEpisodeAction{" +
+ "podcast='" + podcast + '\'' +
+ ", episode='" + episode + '\'' +
+ ", deviceId='" + deviceId + '\'' +
+ ", action=" + action +
+ ", timestamp=" + timestamp +
+ ", started=" + started +
+ ", position=" + position +
+ ", total=" + total +
+ '}';
}
public static class Builder {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeActionGetResponse.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeActionGetResponse.java
index 50420f0a3..1e21efcda 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeActionGetResponse.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetEpisodeActionGetResponse.java
@@ -1,9 +1,7 @@
package de.danoeh.antennapod.core.gpoddernet.model;
-import org.apache.commons.lang3.Validate;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import android.support.annotation.NonNull;
import java.util.List;
@@ -12,8 +10,8 @@ public class GpodnetEpisodeActionGetResponse {
private final List<GpodnetEpisodeAction> episodeActions;
private final long timestamp;
- public GpodnetEpisodeActionGetResponse(List<GpodnetEpisodeAction> episodeActions, long timestamp) {
- Validate.notNull(episodeActions);
+ public GpodnetEpisodeActionGetResponse(@NonNull List<GpodnetEpisodeAction> episodeActions,
+ long timestamp) {
this.episodeActions = episodeActions;
this.timestamp = timestamp;
}
@@ -28,7 +26,9 @@ public class GpodnetEpisodeActionGetResponse {
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ return "GpodnetEpisodeActionGetResponse{" +
+ "episodeActions=" + episodeActions +
+ ", timestamp=" + timestamp +
+ '}';
}
-
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetPodcast.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetPodcast.java
index afebf66ac..191c0fa39 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetPodcast.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetPodcast.java
@@ -1,6 +1,6 @@
package de.danoeh.antennapod.core.gpoddernet.model;
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
public class GpodnetPodcast {
private String url;
@@ -11,12 +11,13 @@ public class GpodnetPodcast {
private String website;
private String mygpoLink;
- public GpodnetPodcast(String url, String title, String description,
- int subscribers, String logoUrl, String website, String mygpoLink) {
- Validate.notNull(url);
- Validate.notNull(title);
- Validate.notNull(description);
-
+ public GpodnetPodcast(@NonNull String url,
+ @NonNull String title,
+ @NonNull String description,
+ int subscribers,
+ String logoUrl,
+ String website,
+ String mygpoLink) {
this.url = url;
this.title = title;
this.description = description;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetSubscriptionChange.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetSubscriptionChange.java
index a5cb8c0f0..6cc9b79a3 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetSubscriptionChange.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetSubscriptionChange.java
@@ -1,6 +1,6 @@
package de.danoeh.antennapod.core.gpoddernet.model;
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
import java.util.List;
@@ -9,11 +9,9 @@ public class GpodnetSubscriptionChange {
private List<String> removed;
private long timestamp;
- public GpodnetSubscriptionChange(List<String> added, List<String> removed,
+ public GpodnetSubscriptionChange(@NonNull List<String> added,
+ @NonNull List<String> removed,
long timestamp) {
- Validate.notNull(added);
- Validate.notNull(removed);
-
this.added = added;
this.removed = removed;
this.timestamp = timestamp;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetTag.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetTag.java
index ee13bef25..42a31afc5 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetTag.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/model/GpodnetTag.java
@@ -2,8 +2,7 @@ package de.danoeh.antennapod.core.gpoddernet.model;
import android.os.Parcel;
import android.os.Parcelable;
-
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
public class GpodnetTag implements Parcelable {
@@ -11,10 +10,7 @@ public class GpodnetTag implements Parcelable {
private final String tag;
private final int usage;
- public GpodnetTag(String title, String tag, int usage) {
- Validate.notNull(title);
- Validate.notNull(tag);
-
+ public GpodnetTag(@NonNull String title, @NonNull String tag, int usage) {
this.title = title;
this.tag = tag;
this.usage = usage;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java
index 1401d5f39..edd7b807a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java
@@ -2,10 +2,9 @@ package de.danoeh.antennapod.core.preferences;
import android.content.Context;
import android.content.SharedPreferences;
+import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -293,7 +292,7 @@ public class GpodnetPreferences {
String[] lines = s.split("\n");
List<GpodnetEpisodeAction> result = new ArrayList<GpodnetEpisodeAction>(lines.length);
for(String line : lines) {
- if(StringUtils.isNotBlank(line)) {
+ if(TextUtils.isEmpty(line)) {
GpodnetEpisodeAction action = GpodnetEpisodeAction.readFromString(line);
if(action != null) {
result.add(GpodnetEpisodeAction.readFromString(line));
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index abb5f1f99..d6ac8496b 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -7,11 +7,11 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
+import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
import org.json.JSONArray;
import org.json.JSONException;
@@ -121,9 +121,8 @@ public class UserPreferences {
*
* @throws IllegalArgumentException if context is null
*/
- public static void init(Context context) {
+ public static void init(@NonNull Context context) {
Log.d(TAG, "Creating new instance of UserPreferences");
- Validate.notNull(context);
UserPreferences.context = context.getApplicationContext();
UserPreferences.prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -152,7 +151,7 @@ public class UserPreferences {
public static List<String> getHiddenDrawerItems() {
String hiddenItems = prefs.getString(PREF_HIDDEN_DRAWER_ITEMS, "");
- return new ArrayList<String>(Arrays.asList(StringUtils.split(hiddenItems, ',')));
+ return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ",")));
}
public static int getFeedOrder() {
@@ -347,7 +346,7 @@ public class UserPreferences {
public static String[] getAutodownloadSelectedNetworks() {
String selectedNetWorks = prefs.getString(PREF_AUTODL_SELECTED_NETWORKS, "");
- return StringUtils.split(selectedNetWorks, ',');
+ return TextUtils.split(selectedNetWorks, ",");
}
public static boolean shouldResumeAfterCall() {
@@ -388,7 +387,7 @@ public class UserPreferences {
public static void setAutodownloadSelectedNetworks(String[] value) {
prefs.edit()
- .putString(PREF_AUTODL_SELECTED_NETWORKS, StringUtils.join(value, ','))
+ .putString(PREF_AUTODL_SELECTED_NETWORKS, TextUtils.join(",", value))
.apply();
}
@@ -422,7 +421,9 @@ public class UserPreferences {
* flattrd. Must be a value between 0 and 1 (inclusive)
* */
public static void setAutoFlattrSettings( boolean enabled, float autoFlattrThreshold) {
- Validate.inclusiveBetween(0.0, 1.0, autoFlattrThreshold);
+ if(autoFlattrThreshold < 0.0 || autoFlattrThreshold > 1.0) {
+ throw new IllegalArgumentException("Flattr threshold must be in range [0.0, 1.0]");
+ }
prefs.edit()
.putBoolean(PREF_AUTO_FLATTR, enabled)
.putFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD, autoFlattrThreshold)
@@ -430,7 +431,7 @@ public class UserPreferences {
}
public static void setHiddenDrawerItems(List<String> items) {
- String str = StringUtils.join(items, ',');
+ String str = TextUtils.join(",", items);
prefs.edit()
.putString(PREF_HIDDEN_DRAWER_ITEMS, str)
.apply();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/AlarmUpdateReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/AlarmUpdateReceiver.java
index 7fa92f30c..ce5004a98 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/receiver/AlarmUpdateReceiver.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/AlarmUpdateReceiver.java
@@ -3,10 +3,9 @@ package de.danoeh.antennapod.core.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
@@ -18,9 +17,9 @@ public class AlarmUpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Received intent");
- if (StringUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) {
+ if (TextUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) {
Log.d(TAG, "Resetting update alarm after reboot");
- } else if (StringUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REPLACED)) {
+ } else if (TextUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REPLACED)) {
Log.d(TAG, "Resetting update alarm after app upgrade");
}
PlaybackPreferences.init(context);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
index 41bbd5ba6..bc3006eea 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
@@ -3,8 +3,7 @@ package de.danoeh.antennapod.core.service.download;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
import de.danoeh.antennapod.core.feed.FeedFile;
import de.danoeh.antennapod.core.util.URLChecker;
@@ -27,11 +26,15 @@ public class DownloadRequest implements Parcelable {
protected long size;
protected int statusMsg;
- public DownloadRequest(String destination, String source, String title,
- long feedfileId, int feedfileType, String username, String password, boolean deleteOnFailure, Bundle arguments) {
- Validate.notNull(destination);
- Validate.notNull(source);
- Validate.notNull(title);
+ public DownloadRequest(@NonNull String destination,
+ @NonNull String source,
+ @NonNull String title,
+ long feedfileId,
+ int feedfileType,
+ String username,
+ String password,
+ boolean deleteOnFailure,
+ Bundle arguments) {
this.destination = destination;
this.source = source;
@@ -260,7 +263,7 @@ public class DownloadRequest implements Parcelable {
private int feedfileType;
private Bundle arguments;
- public Builder(String destination, FeedFile item) {
+ public Builder(@NonNull String destination, @NonNull FeedFile item) {
this.destination = destination;
this.source = URLChecker.prepareURL(item.getDownload_url());
this.title = item.getHumanReadableIdentifier();
@@ -285,9 +288,6 @@ public class DownloadRequest implements Parcelable {
}
public DownloadRequest build() {
- Validate.notNull(destination);
- Validate.notNull(source);
- Validate.notNull(title);
return new DownloadRequest(this);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index 677765e92..f7e084e20 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -14,14 +14,14 @@ import android.media.MediaMetadataRetriever;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
+import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
import android.support.v4.util.Pair;
+import android.text.TextUtils;
import android.util.Log;
import android.webkit.URLUtil;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
import org.apache.http.HttpStatus;
import org.xml.sax.SAXException;
@@ -407,9 +407,11 @@ public class DownloadService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), ACTION_CANCEL_DOWNLOAD)) {
+ if (TextUtils.equals(intent.getAction(), ACTION_CANCEL_DOWNLOAD)) {
String url = intent.getStringExtra(EXTRA_DOWNLOAD_URL);
- Validate.notNull(url, "ACTION_CANCEL_DOWNLOAD intent needs download url extra");
+ if(url == null) {
+ throw new IllegalArgumentException("ACTION_CANCEL_DOWNLOAD intent needs download url extra");
+ }
Log.d(TAG, "Cancelling download with url " + url);
Downloader d = getDownloader(url);
@@ -420,7 +422,7 @@ public class DownloadService extends Service {
}
postDownloaders();
- } else if (StringUtils.equals(intent.getAction(), ACTION_CANCEL_ALL_DOWNLOADS)) {
+ } else if (TextUtils.equals(intent.getAction(), ACTION_CANCEL_ALL_DOWNLOADS)) {
for (Downloader d : downloads) {
d.cancel();
Log.d(TAG, "Cancelled all downloads");
@@ -909,7 +911,7 @@ public class DownloadService extends Service {
FeedItem item1 = feed.getItems().get(x);
FeedItem item2 = feed.getItems().get(y);
if (item1.hasItemImage() && item2.hasItemImage()) {
- if (StringUtils.equals(item1.getImage().getDownload_url(), item2.getImage().getDownload_url())) {
+ if (TextUtils.equals(item1.getImage().getDownload_url(), item2.getImage().getDownload_url())) {
item2.setImage(null);
}
}
@@ -1017,10 +1019,8 @@ public class DownloadService extends Service {
private DownloadRequest request;
private DownloadStatus status;
- public MediaHandlerThread(DownloadStatus status, DownloadRequest request) {
- Validate.notNull(status);
- Validate.notNull(request);
-
+ public MediaHandlerThread(@NonNull DownloadStatus status,
+ @NonNull DownloadRequest request) {
this.status = status;
this.request = request;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
index 21928c94f..ed2b00dfe 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
@@ -1,8 +1,7 @@
package de.danoeh.antennapod.core.service.download;
import android.database.Cursor;
-
-import org.apache.commons.lang3.Validate;
+import android.support.annotation.NonNull;
import java.util.Date;
@@ -62,10 +61,8 @@ public class DownloadStatus {
this.feedfileType = feedfileType;
}
- public DownloadStatus(DownloadRequest request, DownloadError reason,
+ public DownloadStatus(@NonNull DownloadRequest request, DownloadError reason,
boolean successful, boolean cancelled, String reasonDetailed) {
- Validate.notNull(request);
-
this.title = request.getTitle();
this.feedfileId = request.getFeedfileId();
this.feedfileType = request.getFeedfileType();
@@ -77,10 +74,8 @@ public class DownloadStatus {
}
/** Constructor for creating new completed downloads. */
- public DownloadStatus(FeedFile feedfile, String title, DownloadError reason,
- boolean successful, String reasonDetailed) {
- Validate.notNull(feedfile);
-
+ public DownloadStatus(@NonNull FeedFile feedfile, String title, DownloadError reason,
+ boolean successful, String reasonDetailed) {
this.title = title;
this.done = true;
this.feedfileId = feedfile.getId();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
index eda857bd5..9f54db477 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
@@ -1,5 +1,6 @@
package de.danoeh.antennapod.core.service.download;
+import android.text.TextUtils;
import android.util.Log;
import com.squareup.okhttp.OkHttpClient;
@@ -10,7 +11,6 @@ import com.squareup.okhttp.ResponseBody;
import com.squareup.okhttp.internal.http.HttpDate;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import java.io.BufferedInputStream;
@@ -86,7 +86,7 @@ public class HttpDownloader extends Downloader {
String credentials = encodeCredentials(parts[0], parts[1], "ISO-8859-1");
httpReq.header("Authorization", credentials);
}
- } else if (!StringUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
+ } else if (!TextUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
String credentials = encodeCredentials(request.getUsername(), request.getPassword(),
"ISO-8859-1");
httpReq.header("Authorization", credentials);
@@ -114,7 +114,10 @@ public class HttpDownloader extends Downloader {
}
responseBody = response.body();
String contentEncodingHeader = response.header("Content-Encoding");
- boolean isGzip = StringUtils.equalsIgnoreCase(contentEncodingHeader, "gzip");
+ boolean isGzip = false;
+ if(!TextUtils.isEmpty(contentEncodingHeader)) {
+ isGzip = TextUtils.equals(contentEncodingHeader.toLowerCase(), "gzip");
+ }
Log.d(TAG, "Response code is " + response.code());
@@ -126,7 +129,7 @@ public class HttpDownloader extends Downloader {
String credentials = encodeCredentials(parts[0], parts[1], "UTF-8");
httpReq.header("Authorization", credentials);
}
- } else if (!StringUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
+ } else if (!TextUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
String credentials = encodeCredentials(request.getUsername(), request.getPassword(),
"UTF-8");
httpReq.header("Authorization", credentials);
@@ -134,7 +137,9 @@ public class HttpDownloader extends Downloader {
response = httpClient.newCall(httpReq.build()).execute();
responseBody = response.body();
contentEncodingHeader = response.header("Content-Encoding");
- isGzip = StringUtils.equalsIgnoreCase(contentEncodingHeader, "gzip");
+ if(!TextUtils.isEmpty(contentEncodingHeader)) {
+ isGzip = TextUtils.equals(contentEncodingHeader.toLowerCase(), "gzip");
+ }
}
if(!response.isSuccessful() && response.code() == HttpURLConnection.HTTP_NOT_MODIFIED) {
@@ -167,7 +172,7 @@ public class HttpDownloader extends Downloader {
String contentRangeHeader = (fileExists) ? response.header("Content-Range") : null;
if (fileExists && response.code() == HttpStatus.SC_PARTIAL_CONTENT
- && !StringUtils.isEmpty(contentRangeHeader)) {
+ && !TextUtils.isEmpty(contentRangeHeader)) {
String start = contentRangeHeader.substring("bytes ".length(),
contentRangeHeader.indexOf("-"));
request.setSoFar(Long.valueOf(start));
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 5e0738cb8..1313d9607 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -20,6 +20,7 @@ import android.os.IBinder;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
@@ -28,8 +29,6 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
-import org.apache.commons.lang3.StringUtils;
-
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -1019,7 +1018,7 @@ public class PlaybackService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), Intent.ACTION_HEADSET_PLUG)) {
+ if (TextUtils.equals(intent.getAction(), Intent.ACTION_HEADSET_PLUG)) {
int state = intent.getIntExtra("state", -1);
if (state != -1) {
Log.d(TAG, "Headset plug event. State is " + state);
@@ -1041,7 +1040,7 @@ public class PlaybackService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
- if (StringUtils.equals(intent.getAction(), BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) {
+ if (TextUtils.equals(intent.getAction(), BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) {
int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, -1);
if (state == BluetoothA2dp.STATE_CONNECTED) {
Log.d(TAG, "Received bluetooth connection intent");
@@ -1102,7 +1101,7 @@ public class PlaybackService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
+ if (TextUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
stopSelf();
}
}
@@ -1112,7 +1111,7 @@ public class PlaybackService extends Service {
private final BroadcastReceiver skipCurrentEpisodeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), ACTION_SKIP_CURRENT_EPISODE)) {
+ if (TextUtils.equals(intent.getAction(), ACTION_SKIP_CURRENT_EPISODE)) {
Log.d(TAG, "Received SKIP_CURRENT_EPISODE intent");
mediaPlayer.endPlayback(true);
}
@@ -1122,7 +1121,7 @@ public class PlaybackService extends Service {
private final BroadcastReceiver pauseResumeCurrentEpisodeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), ACTION_RESUME_PLAY_CURRENT_EPISODE)) {
+ if (TextUtils.equals(intent.getAction(), ACTION_RESUME_PLAY_CURRENT_EPISODE)) {
Log.d(TAG, "Received RESUME_PLAY_CURRENT_EPISODE intent");
mediaPlayer.resume();
}
@@ -1132,7 +1131,7 @@ public class PlaybackService extends Service {
private final BroadcastReceiver pausePlayCurrentEpisodeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (StringUtils.equals(intent.getAction(), ACTION_PAUSE_PLAY_CURRENT_EPISODE)) {
+ if (TextUtils.equals(intent.getAction(), ACTION_PAUSE_PLAY_CURRENT_EPISODE)) {
Log.d(TAG, "Received PAUSE_PLAY_CURRENT_EPISODE intent");
mediaPlayer.pause(false, false);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
index 7247c6bdf..6ad376bf0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
@@ -10,6 +10,7 @@ import android.media.AudioManager;
import android.net.wifi.WifiManager;
import android.os.PowerManager;
import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
@@ -23,8 +24,6 @@ import android.view.SurfaceHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.Target;
-import org.apache.commons.lang3.Validate;
-
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
@@ -92,10 +91,8 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
*/
private WifiManager.WifiLock wifiLock;
- public PlaybackServiceMediaPlayer(Context context, PSMPCallback callback) {
- Validate.notNull(context);
- Validate.notNull(callback);
-
+ public PlaybackServiceMediaPlayer(@NonNull Context context,
+ @NonNull PSMPCallback callback) {
this.context = context;
this.callback = callback;
this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
@@ -175,9 +172,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
* for playback immediately (see 'prepareImmediately' parameter for more details)
* @param prepareImmediately Set to true if the method should also prepare the episode for playback.
*/
- public void playMediaObject(final Playable playable, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) {
- Validate.notNull(playable);
-
+ public void playMediaObject(@NonNull final Playable playable, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) {
Log.d(TAG, "playMediaObject(...)");
executor.submit(new Runnable() {
@Override
@@ -203,8 +198,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
*
* @see #playMediaObject(de.danoeh.antennapod.core.util.playback.Playable, boolean, boolean, boolean)
*/
- private void playMediaObject(final Playable playable, final boolean forceReset, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) {
- Validate.notNull(playable);
+ private void playMediaObject(@NonNull final Playable playable, final boolean forceReset, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) {
if (!playerLock.isHeldByCurrentThread()) {
throw new IllegalStateException("method requires playerLock");
}
@@ -573,9 +567,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
/**
* Seek to the start of the specified chapter.
*/
- public void seekToChapter(Chapter c) {
- Validate.notNull(c);
-
+ public void seekToChapter(@NonNull Chapter c) {
seekTo((int) c.getStart());
}
@@ -840,9 +832,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
* @param newStatus The new PlayerStatus. This must not be null.
* @param newMedia The new playable object of the PSMP object. This can be null.
*/
- private synchronized void setPlayerStatus(PlayerStatus newStatus, Playable newMedia) {
- Validate.notNull(newStatus);
-
+ private synchronized void setPlayerStatus(@NonNull PlayerStatus newStatus, Playable newMedia) {
Log.d(TAG, "Setting player status to " + newStatus);
this.playerStatus = newStatus;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceTaskManager.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceTaskManager.java
index 961f923e9..4e0c8a109 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceTaskManager.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceTaskManager.java
@@ -2,10 +2,9 @@ package de.danoeh.antennapod.core.service.playback;
import android.content.Context;
import android.os.Vibrator;
+import android.support.annotation.NonNull;
import android.util.Log;
-import org.apache.commons.lang3.Validate;
-
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -15,8 +14,8 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
-import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.event.QueueEvent;
+import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.greenrobot.event.EventBus;
@@ -62,10 +61,8 @@ public class PlaybackServiceTaskManager {
* @param context
* @param callback A PSTMCallback object for notifying the user about updates. Must not be null.
*/
- public PlaybackServiceTaskManager(Context context, PSTMCallback callback) {
- Validate.notNull(context);
- Validate.notNull(callback);
-
+ public PlaybackServiceTaskManager(@NonNull Context context,
+ @NonNull PSTMCallback callback) {
this.context = context;
this.callback = callback;
schedExecutor = new ScheduledThreadPoolExecutor(SCHED_EX_POOL_SIZE, new ThreadFactory() {
@@ -200,7 +197,9 @@ public class PlaybackServiceTaskManager {
* @throws java.lang.IllegalArgumentException if waitingTime <= 0
*/
public synchronized void setSleepTimer(long waitingTime, boolean shakeToReset, boolean vibrate) {
- Validate.isTrue(waitingTime > 0, "Waiting time <= 0");
+ if(waitingTime <= 0) {
+ throw new IllegalArgumentException("Waiting time <= 0");
+ }
Log.d(TAG, "Setting sleep timer to " + Long.toString(waitingTime) + " milliseconds");
if (isSleepTimerActive()) {
@@ -275,9 +274,7 @@ public class PlaybackServiceTaskManager {
* it will be cancelled first.
* On completion, the callback's onChapterLoaded method will be called.
*/
- public synchronized void startChapterLoader(final Playable media) {
- Validate.notNull(media);
-
+ public synchronized void startChapterLoader(@NonNull final Playable media) {
if (isChapterLoaderActive()) {
cancelChapterLoader();
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index c0a30f740..c34515118 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -225,12 +225,12 @@ public final class DBReader {
private static Map<Long,FeedMedia> getFeedMedia(PodDBAdapter adapter,
long... itemIds) {
- ArrayList<String> ids = new ArrayList<>(itemIds.length);
- for(long itemId : itemIds) {
- ids.add(String.valueOf(itemId));
+ String[] ids = new String[itemIds.length];
+ for(int i=0, len=itemIds.length; i < len; i++) {
+ ids[i] = String.valueOf(itemIds[i]);
}
Map<Long,FeedMedia> result = new HashMap<>(itemIds.length);
- Cursor cursor = adapter.getFeedMediaCursor(ids.toArray(new String[0]));
+ Cursor cursor = adapter.getFeedMediaCursor(ids);
try {
if (cursor.moveToFirst()) {
do {
@@ -862,10 +862,14 @@ public final class DBReader {
/**
* Searches the DB for a FeedImage of the given id.
*
- * @param ids The id of the object
- * @return The found object
+ * @param imageIds The ids of the images
+ * @return Map that associates the id of an image with the image itself
*/
- private static Map<Long,FeedImage> getFeedImages(PodDBAdapter adapter, final long... ids) {
+ private static Map<Long,FeedImage> getFeedImages(PodDBAdapter adapter, final long... imageIds) {
+ String[] ids = new String[imageIds.length];
+ for(int i=0, len=imageIds.length; i < len; i++) {
+ ids[i] = String.valueOf(imageIds[i]);
+ }
Cursor cursor = adapter.getImageCursor(ids);
Map<Long, FeedImage> result = new HashMap<>(cursor.getCount());
try {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
index ee079c068..0dc1dadeb 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
@@ -3,12 +3,12 @@ package de.danoeh.antennapod.core.storage;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
import android.util.Log;
import android.webkit.URLUtil;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
import java.io.File;
import java.util.Map;
@@ -71,10 +71,8 @@ public class DownloadRequester {
* call will return false.
* @return True if the download request was accepted, false otherwise.
*/
- public synchronized boolean download(Context context, DownloadRequest request) {
- Validate.notNull(context);
- Validate.notNull(request);
-
+ public synchronized boolean download(@NonNull Context context,
+ @NonNull DownloadRequest request) {
if (downloads.containsKey(request.getSource())) {
if (BuildConfig.DEBUG) Log.i(TAG, "DownloadRequest is already stored.");
return false;
@@ -145,7 +143,7 @@ public class DownloadRequester {
private boolean isFilenameAvailable(String path) {
for (String key : downloads.keySet()) {
DownloadRequest r = downloads.get(key);
- if (StringUtils.equals(r.getDestination(), path)) {
+ if (TextUtils.equals(r.getDestination(), path)) {
if (BuildConfig.DEBUG)
Log.d(TAG, path
+ " is already used by another requested download");
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index bf324c9d1..97d91ccd3 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -14,9 +14,6 @@ import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
-
import java.util.Arrays;
import java.util.List;
@@ -1018,15 +1015,42 @@ public class PodDBAdapter {
/**
* Returns a cursor for a DB query in the FeedImages table for given IDs.
*
- * @param ids IDs of the FeedImages
+ * @param imageIds IDs of the images
* @return The cursor of the query
*/
- public final Cursor getImageCursor(long... ids) {
- String sql = "SELECT * FROM " + TABLE_NAME_FEED_IMAGES +
- " WHERE " + KEY_ID + " IN (" + StringUtils.join(ids, ',') + ")";
- Cursor c = db.rawQuery(sql, null);
+ public final Cursor getImageCursor(String... imageIds) {
+ int length = imageIds.length;
+ if (length > IN_OPERATOR_MAXIMUM) {
+ Log.w(TAG, "Length of id array is larger than "
+ + IN_OPERATOR_MAXIMUM + ". Creating multiple cursors");
+ int numCursors = (int) (((double) length) / (IN_OPERATOR_MAXIMUM)) + 1;
+ Cursor[] cursors = new Cursor[numCursors];
+ for (int i = 0; i < numCursors; i++) {
+ int neededLength;
+ String[] parts;
+ final int elementsLeft = length - i * IN_OPERATOR_MAXIMUM;
- return c;
+ if (elementsLeft >= IN_OPERATOR_MAXIMUM) {
+ neededLength = IN_OPERATOR_MAXIMUM;
+ parts = Arrays.copyOfRange(imageIds, i
+ * IN_OPERATOR_MAXIMUM, (i + 1)
+ * IN_OPERATOR_MAXIMUM);
+ } else {
+ neededLength = elementsLeft;
+ parts = Arrays.copyOfRange(imageIds, i
+ * IN_OPERATOR_MAXIMUM, (i * IN_OPERATOR_MAXIMUM)
+ + neededLength);
+ }
+
+ cursors[i] = db.rawQuery("SELECT * FROM "
+ + TABLE_NAME_FEED_IMAGES + " WHERE " + KEY_ID + " IN "
+ + buildInOperator(neededLength), parts);
+ }
+ return new MergeCursor(cursors);
+ } else {
+ return db.query(TABLE_NAME_FEED_IMAGES, null, KEY_ID + " IN "
+ + buildInOperator(length), imageIds, null, null, null);
+ }
}
public final Cursor getSimpleChaptersOfFeedItemCursor(final FeedItem item) {
@@ -1154,7 +1178,9 @@ public class PodDBAdapter {
* @throws IllegalArgumentException if limit < 0
*/
public final Cursor getCompletedMediaCursor(int limit) {
- Validate.isTrue(limit >= 0, "Limit must be >= 0");
+ if(limit < 0) {
+ throw new IllegalArgumentException("Limit must be >= 0");
+ }
Cursor c = db.query(TABLE_NAME_FEED_MEDIA, null,
KEY_PLAYBACK_COMPLETION_DATE + " > 0", null, null,
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java b/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java
index 4300556d2..415a1d3a2 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java
@@ -3,8 +3,6 @@ package de.danoeh.antennapod.core.util;
import android.net.Uri;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
-
import de.danoeh.antennapod.core.BuildConfig;
/**
@@ -32,19 +30,19 @@ public final class URLChecker {
* @return The prepared url
*/
public static String prepareURL(String url) {
- url = StringUtils.trim(url);
+ url = url.trim();
if (url.startsWith("feed://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
return url.replaceFirst("feed://", "http://");
} else if (url.startsWith("pcast://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://");
- return prepareURL(StringUtils.removeStart(url, "pcast://"));
+ return prepareURL(url.substring("pcast://".length()));
} else if (url.startsWith("itpc")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing itpc:// with http://");
return url.replaceFirst("itpc://", "http://");
} else if (url.startsWith(AP_SUBSCRIBE)) {
if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://");
- return prepareURL(StringUtils.removeStart(url, AP_SUBSCRIBE));
+ return prepareURL(url.substring(AP_SUBSCRIBE.length()));
} else if (!(url.startsWith("http://") || url.startsWith("https://"))) {
if (BuildConfig.DEBUG) Log.d(TAG, "Adding http:// at the beginning of the URL");
return "http://" + url;
@@ -66,7 +64,7 @@ public final class URLChecker {
if (base == null) {
return prepareURL(url);
}
- url = StringUtils.trim(url);
+ url = url.trim();
base = prepareURL(base);
Uri urlUri = Uri.parse(url);
Uri baseUri = Uri.parse(base);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
index 318839e1d..6ddfb0366 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
@@ -8,9 +8,9 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog;
+import android.text.TextUtils;
import android.util.Log;
-import org.apache.commons.lang3.StringUtils;
import org.shredzone.flattr4j.FlattrService;
import org.shredzone.flattr4j.exception.FlattrException;
import org.shredzone.flattr4j.model.Flattr;
@@ -78,8 +78,8 @@ public class FlattrUtils {
* Returns true if FLATTR_APP_KEY and FLATTR_APP_SECRET in BuildConfig are not null and not empty
*/
public static boolean hasAPICredentials() {
- return StringUtils.isNotEmpty(ClientConfig.flattrCallbacks.getFlattrAppKey())
- && StringUtils.isNotEmpty(ClientConfig.flattrCallbacks.getFlattrAppSecret());
+ return !TextUtils.isEmpty(ClientConfig.flattrCallbacks.getFlattrAppKey())
+ && !TextUtils.isEmpty(ClientConfig.flattrCallbacks.getFlattrAppSecret());
}
public static boolean hasToken() {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
index 4eb955913..a519fb555 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
@@ -13,6 +13,8 @@ import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.IBinder;
import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.SurfaceHolder;
@@ -22,9 +24,6 @@ import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
-
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -74,8 +73,7 @@ public abstract class PlaybackController {
*/
private boolean reinitOnPause;
- public PlaybackController(Activity activity, boolean reinitOnPause) {
- Validate.notNull(activity);
+ public PlaybackController(@NonNull Activity activity, boolean reinitOnPause) {
this.activity = activity;
this.reinitOnPause = reinitOnPause;
@@ -360,7 +358,7 @@ public abstract class PlaybackController {
@Override
public void onReceive(Context context, Intent intent) {
if (isConnectedToPlaybackService()) {
- if (StringUtils.equals(intent.getAction(),
+ if (TextUtils.equals(intent.getAction(),
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
release();
onShutdownNotification();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
index 0de9863e7..00f2e6f57 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
@@ -2,10 +2,10 @@ package de.danoeh.antennapod.core.util.playback;
import android.content.Context;
import android.content.res.TypedArray;
+import android.support.annotation.NonNull;
import android.util.Log;
import android.util.TypedValue;
-import org.apache.commons.lang3.Validate;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -158,8 +158,7 @@ public class Timeline {
}
- public void setShownotesProvider(ShownotesProvider shownotesProvider) {
- Validate.notNull(shownotesProvider);
+ public void setShownotesProvider(@NonNull ShownotesProvider shownotesProvider) {
this.shownotesProvider = shownotesProvider;
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/syndication/FeedDiscoverer.java b/core/src/main/java/de/danoeh/antennapod/core/util/syndication/FeedDiscoverer.java
index 9588265b8..d148419fd 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/syndication/FeedDiscoverer.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/syndication/FeedDiscoverer.java
@@ -1,7 +1,8 @@
package de.danoeh.antennapod.core.util.syndication;
import android.net.Uri;
-import org.apache.commons.lang3.StringUtils;
+import android.text.TextUtils;
+
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -50,7 +51,7 @@ public class FeedDiscoverer {
for (Element link : links) {
String rel = link.attr("rel");
String href = link.attr("href");
- if (!StringUtils.isEmpty(href) &&
+ if (!TextUtils.isEmpty(href) &&
(rel.equals("alternate") || rel.equals("feed"))) {
String type = link.attr("type");
if (type.equals(MIME_RSS) || type.equals(MIME_ATOM)) {
@@ -58,7 +59,7 @@ public class FeedDiscoverer {
String processedUrl = processURL(baseUrl, href);
if (processedUrl != null) {
res.put(processedUrl,
- (StringUtils.isEmpty(title)) ? href : title);
+ (TextUtils.isEmpty(title)) ? href : title);
}
}
}