Increased use of library methods
This commit is contained in:
parent
60214f6306
commit
fb1fcb0600
|
@ -16,16 +16,27 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.*;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView.ScaleType;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.ChapterListAdapter;
|
||||
import de.danoeh.antennapod.adapter.NavListAdapter;
|
||||
import de.danoeh.antennapod.asynctask.ImageLoader;
|
||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||
import de.danoeh.antennapod.feed.*;
|
||||
import de.danoeh.antennapod.feed.Chapter;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.MediaType;
|
||||
import de.danoeh.antennapod.feed.SimpleChapter;
|
||||
import de.danoeh.antennapod.fragment.CoverFragment;
|
||||
import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
@ -215,8 +226,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (getIntent().getAction() != null
|
||||
&& getIntent().getAction().equals(Intent.ACTION_VIEW)) {
|
||||
if (StringUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
|
||||
Intent intent = getIntent();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received VIEW intent: "
|
||||
|
|
|
@ -9,6 +9,9 @@ import android.view.View;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
@ -58,7 +61,8 @@ public class DownloadAuthenticationActivity extends ActionBarActivity {
|
|||
butCancel = (Button) findViewById(R.id.butCancel);
|
||||
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
|
||||
|
||||
if (!getIntent().hasExtra(ARG_DOWNLOAD_REQUEST)) throw new IllegalArgumentException("Download request missing");
|
||||
Validate.isTrue(getIntent().hasExtra(ARG_DOWNLOAD_REQUEST), "Download request missing");
|
||||
|
||||
request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
|
||||
sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false);
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ import android.util.Log;
|
|||
import android.view.*;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.NavListAdapter;
|
||||
|
@ -219,7 +222,7 @@ public class MainActivity extends ActionBarActivity {
|
|||
}
|
||||
|
||||
public void loadChildFragment(Fragment fragment) {
|
||||
if (fragment == null) throw new IllegalArgumentException("fragment = null");
|
||||
Validate.notNull(fragment);
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
fm.beginTransaction()
|
||||
.replace(R.id.main_view, fragment, "main")
|
||||
|
|
|
@ -7,6 +7,9 @@ import android.content.IntentFilter;
|
|||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
@ -54,7 +57,7 @@ public class StorageErrorActivity extends ActionBarActivity {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
|
||||
if (StringUtils.equals(intent.getAction(), Intent.ACTION_MEDIA_MOUNTED)) {
|
||||
if (intent.getBooleanExtra("read-only", true)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Media was mounted; Finishing activity");
|
||||
|
|
|
@ -4,6 +4,9 @@ import android.content.Context;
|
|||
import android.content.res.TypedArray;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
|
@ -20,7 +23,8 @@ public class ActionButtonUtils {
|
|||
private final Context context;
|
||||
|
||||
public ActionButtonUtils(Context context) {
|
||||
if (context == null) throw new IllegalArgumentException("context = null");
|
||||
Validate.notNull(context);
|
||||
|
||||
this.context = context;
|
||||
drawables = context.obtainStyledAttributes(new int[]{
|
||||
R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download, R.attr.navigation_chapters});
|
||||
|
@ -32,7 +36,8 @@ public class ActionButtonUtils {
|
|||
* action button so that it matches the state of the FeedItem.
|
||||
*/
|
||||
public void configureActionButton(ImageButton butSecondary, FeedItem item) {
|
||||
if (butSecondary == null || item == null) throw new IllegalArgumentException("butSecondary or item was null");
|
||||
Validate.isTrue(butSecondary != null && item != null, "butSecondary or item was null");
|
||||
|
||||
final FeedMedia media = item.getMedia();
|
||||
if (media != null) {
|
||||
final boolean isDownloadingMedia = DownloadRequester.getInstance().isDownloadingFile(media);
|
||||
|
|
|
@ -2,6 +2,9 @@ package de.danoeh.antennapod.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
|
@ -19,7 +22,7 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
|
|||
private final Context context;
|
||||
|
||||
public DefaultActionButtonCallback(Context context) {
|
||||
if (context == null) throw new IllegalArgumentException("context = null");
|
||||
Validate.notNull(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ import android.content.*;
|
|||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.service.download.Downloader;
|
||||
|
@ -45,9 +48,9 @@ public class DownloadObserver {
|
|||
* @throws java.lang.IllegalArgumentException if one of the arguments is null.
|
||||
*/
|
||||
public DownloadObserver(Activity activity, Handler handler, Callback callback) {
|
||||
if (activity == null) throw new IllegalArgumentException("activity = null");
|
||||
if (handler == null) throw new IllegalArgumentException("handler = null");
|
||||
if (callback == null) throw new IllegalArgumentException("callback = null");
|
||||
Validate.notNull(activity);
|
||||
Validate.notNull(handler);
|
||||
Validate.notNull(callback);
|
||||
|
||||
this.activity = activity;
|
||||
this.handler = handler;
|
||||
|
@ -166,7 +169,7 @@ public class DownloadObserver {
|
|||
}
|
||||
|
||||
public void setActivity(Activity activity) {
|
||||
if (activity == null) throw new IllegalArgumentException("activity = null");
|
||||
Validate.notNull(activity);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ 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;
|
||||
|
@ -65,7 +66,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) {
|
||||
if (context == null) throw new IllegalArgumentException("context = null");
|
||||
Validate.notNull(context);
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import de.danoeh.antennapod.service.download.DownloadRequest;
|
|||
import de.danoeh.antennapod.service.download.HttpDownloader;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,9 +49,8 @@ public class ImageDiskCache {
|
|||
* Return an instance of an ImageDiskCache that stores images in the specified folder.
|
||||
*/
|
||||
public static synchronized ImageDiskCache getInstance(String path, long maxCacheSize) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull(path);
|
||||
|
||||
if (cacheSingletons.containsKey(path)) {
|
||||
return cacheSingletons.get(path);
|
||||
}
|
||||
|
@ -358,9 +358,7 @@ public class ImageDiskCache {
|
|||
private final long size;
|
||||
|
||||
public DiskCacheObject(String fileUrl, long size) {
|
||||
if (fileUrl == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull(fileUrl);
|
||||
this.fileUrl = fileUrl;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.size = size;
|
||||
|
|
|
@ -36,6 +36,7 @@ import de.danoeh.antennapod.util.QueueAccess;
|
|||
import de.danoeh.antennapod.util.ShownotesProvider;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -59,7 +60,7 @@ public class FeedItemDialog extends Dialog {
|
|||
private PopupMenu popupMenu;
|
||||
|
||||
public static FeedItemDialog newInstance(Context context, FeedItemDialogSavedInstance savedInstance) {
|
||||
if (savedInstance == null) throw new IllegalArgumentException("savedInstance = null");
|
||||
Validate.notNull(savedInstance);
|
||||
FeedItemDialog dialog = newInstance(context, savedInstance.item, savedInstance.queueAccess);
|
||||
if (savedInstance.isShowing) {
|
||||
dialog.show();
|
||||
|
@ -77,8 +78,8 @@ public class FeedItemDialog extends Dialog {
|
|||
|
||||
public FeedItemDialog(Context context, int theme, FeedItem item, QueueAccess queue) {
|
||||
super(context, theme);
|
||||
if (item == null) throw new IllegalArgumentException("item = null");
|
||||
if (queue == null) throw new IllegalArgumentException("queue = null");
|
||||
Validate.notNull(item);
|
||||
Validate.notNull(queue);
|
||||
this.item = item;
|
||||
this.queue = queue;
|
||||
}
|
||||
|
@ -350,7 +351,7 @@ public class FeedItemDialog extends Dialog {
|
|||
|
||||
|
||||
public void setItem(FeedItem item) {
|
||||
if (item == null) throw new IllegalArgumentException("item = null");
|
||||
Validate.notNull(item);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
@ -371,7 +372,7 @@ public class FeedItemDialog extends Dialog {
|
|||
}
|
||||
|
||||
public void setQueue(QueueAccess queue) {
|
||||
if (queue == null) throw new IllegalArgumentException("queue = null");
|
||||
Validate.notNull(queue);
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@ package de.danoeh.antennapod.feed;
|
|||
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
|
||||
import java.util.AbstractQueue;
|
||||
|
@ -90,10 +93,7 @@ public class EventDistributor extends Observable {
|
|||
@Override
|
||||
public void addObserver(Observer observer) {
|
||||
super.addObserver(observer);
|
||||
if (!(observer instanceof EventListener)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Observer must be instance of EventListener");
|
||||
}
|
||||
Validate.isInstanceOf(EventListener.class, observer);
|
||||
}
|
||||
|
||||
public void sendDownloadQueuedBroadcast() {
|
||||
|
|
|
@ -17,6 +17,9 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.FeedInfoActivity;
|
||||
|
@ -97,7 +100,7 @@ public class ItemlistFragment extends ListFragment {
|
|||
setHasOptionsMenu(true);
|
||||
|
||||
Bundle args = getArguments();
|
||||
if (args == null) throw new IllegalArgumentException("args invalid");
|
||||
Validate.notNull(args);
|
||||
feedID = args.getLong(ARGUMENT_FEED_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@ import android.os.Bundle;
|
|||
import android.support.v7.widget.SearchView;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.fragment.SearchFragment;
|
||||
|
@ -68,9 +71,8 @@ public class SearchListFragment extends PodcastListFragment {
|
|||
}
|
||||
|
||||
public void changeQuery(String query) {
|
||||
if (query == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull(query);
|
||||
|
||||
this.query = query;
|
||||
loadData();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package de.danoeh.antennapod.fragment.gpodnet;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.gpoddernet.GpodnetServiceException;
|
||||
|
@ -21,7 +24,7 @@ public class TagFragment extends PodcastListFragment {
|
|||
private GpodnetTag tag;
|
||||
|
||||
public static TagFragment newInstance(String tagName) {
|
||||
if (tagName == null) throw new IllegalArgumentException("tagName = null");
|
||||
Validate.notNull(tagName);
|
||||
TagFragment fragment = new TagFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("tag", tagName);
|
||||
|
@ -34,7 +37,7 @@ public class TagFragment extends PodcastListFragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle args = getArguments();
|
||||
if (args == null || args.getString("tag") == null) throw new IllegalArgumentException("args invalid");
|
||||
Validate.isTrue(args != null && args.getString("tag") != null, "args invalid");
|
||||
|
||||
tag = new GpodnetTag(args.getString("tag"));
|
||||
((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(tag.getName());
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package de.danoeh.antennapod.gpoddernet;
|
||||
|
||||
import de.danoeh.antennapod.gpoddernet.model.*;
|
||||
import de.danoeh.antennapod.preferences.GpodnetPreferences;
|
||||
import de.danoeh.antennapod.service.download.AntennapodHttpClient;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -32,6 +30,14 @@ import java.util.Collection;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetDevice;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetPodcast;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetSubscriptionChange;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetTag;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetUploadChangesResponse;
|
||||
import de.danoeh.antennapod.preferences.GpodnetPreferences;
|
||||
import de.danoeh.antennapod.service.download.AntennapodHttpClient;
|
||||
|
||||
/**
|
||||
* Communicates with the gpodder.net service.
|
||||
*/
|
||||
|
@ -89,10 +95,8 @@ public class GpodnetService {
|
|||
*/
|
||||
public List<GpodnetPodcast> getPodcastsForTag(GpodnetTag tag, int count)
|
||||
throws GpodnetServiceException {
|
||||
if (tag == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Tag and title of tag must not be null");
|
||||
}
|
||||
Validate.notNull(tag);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/api/2/tag/%s/%d.json", tag.getName(), count), null);
|
||||
|
@ -120,9 +124,8 @@ public class GpodnetService {
|
|||
*/
|
||||
public List<GpodnetPodcast> getPodcastToplist(int count)
|
||||
throws GpodnetServiceException {
|
||||
if (count < 1 || count > 100) {
|
||||
throw new IllegalArgumentException("Count must be in range 1..100");
|
||||
}
|
||||
Validate.isTrue(count >= 1 && count <= 100, "Count must be in range 1..100");
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/toplist/%d.json", count), null);
|
||||
|
@ -155,9 +158,8 @@ public class GpodnetService {
|
|||
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
|
||||
*/
|
||||
public List<GpodnetPodcast> getSuggestions(int count) throws GpodnetServiceException {
|
||||
if (count < 1 || count > 100) {
|
||||
throw new IllegalArgumentException("Count must be in range 1..100");
|
||||
}
|
||||
Validate.isTrue(count >= 1 && count <= 100, "Count must be in range 1..100");
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/suggestions/%d.json", count), null);
|
||||
|
@ -220,9 +222,8 @@ public class GpodnetService {
|
|||
*/
|
||||
public List<GpodnetDevice> getDevices(String username)
|
||||
throws GpodnetServiceException {
|
||||
if (username == null) {
|
||||
throw new IllegalArgumentException("Username must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/api/2/devices/%s.json", username), null);
|
||||
|
@ -255,10 +256,9 @@ public class GpodnetService {
|
|||
public void configureDevice(String username, String deviceId,
|
||||
String caption, GpodnetDevice.DeviceType type)
|
||||
throws GpodnetServiceException {
|
||||
if (username == null || deviceId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Username and device ID must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
Validate.notNull(deviceId);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/api/2/devices/%s/%s.json", username, deviceId), null);
|
||||
|
@ -303,10 +303,9 @@ public class GpodnetService {
|
|||
*/
|
||||
public String getSubscriptionsOfDevice(String username, String deviceId)
|
||||
throws GpodnetServiceException {
|
||||
if (username == null || deviceId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Username and device ID must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
Validate.notNull(deviceId);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/subscriptions/%s/%s.opml", username, deviceId), null);
|
||||
|
@ -332,9 +331,8 @@ public class GpodnetService {
|
|||
*/
|
||||
public String getSubscriptionsOfUser(String username)
|
||||
throws GpodnetServiceException {
|
||||
if (username == null) {
|
||||
throw new IllegalArgumentException("Username must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/subscriptions/%s.opml", username), null);
|
||||
|
@ -406,10 +404,11 @@ public class GpodnetService {
|
|||
*/
|
||||
public GpodnetUploadChangesResponse uploadChanges(String username, String deviceId, Collection<String> added,
|
||||
Collection<String> removed) throws GpodnetServiceException {
|
||||
if (username == null || deviceId == null || added == null || removed == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Username, device ID, added and removed must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
Validate.notNull(deviceId);
|
||||
Validate.notNull(added);
|
||||
Validate.notNull(removed);
|
||||
|
||||
try {
|
||||
URI uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
"/api/2/subscriptions/%s/%s.json", username, deviceId), null);
|
||||
|
@ -453,10 +452,9 @@ public class GpodnetService {
|
|||
*/
|
||||
public GpodnetSubscriptionChange getSubscriptionChanges(String username,
|
||||
String deviceId, long timestamp) throws GpodnetServiceException {
|
||||
if (username == null || deviceId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Username and device ID must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
Validate.notNull(deviceId);
|
||||
|
||||
String params = String.format("since=%d", timestamp);
|
||||
String path = String.format("/api/2/subscriptions/%s/%s.json",
|
||||
username, deviceId);
|
||||
|
@ -486,10 +484,9 @@ public class GpodnetService {
|
|||
*/
|
||||
public void authenticate(String username, String password)
|
||||
throws GpodnetServiceException {
|
||||
if (username == null || password == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Username and password must not be null");
|
||||
}
|
||||
Validate.notNull(username);
|
||||
Validate.notNull(password);
|
||||
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||
|
@ -517,9 +514,8 @@ public class GpodnetService {
|
|||
|
||||
private String executeRequest(HttpRequestBase request)
|
||||
throws GpodnetServiceException {
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("request must not be null");
|
||||
}
|
||||
Validate.notNull(request);
|
||||
|
||||
String responseString = null;
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
|
@ -586,9 +582,8 @@ public class GpodnetService {
|
|||
|
||||
private String getStringFromEntity(HttpEntity entity)
|
||||
throws GpodnetServiceException {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("entity must not be null");
|
||||
}
|
||||
Validate.notNull(entity);
|
||||
|
||||
ByteArrayOutputStream outputStream;
|
||||
int contentLength = (int) entity.getContentLength();
|
||||
if (contentLength > 0) {
|
||||
|
@ -613,9 +608,7 @@ public class GpodnetService {
|
|||
|
||||
private void checkStatusCode(HttpResponse response)
|
||||
throws GpodnetServiceException {
|
||||
if (response == null) {
|
||||
throw new IllegalArgumentException("response must not be null");
|
||||
}
|
||||
Validate.notNull(response);
|
||||
int responseCode = response.getStatusLine().getStatusCode();
|
||||
if (responseCode != HttpStatus.SC_OK) {
|
||||
if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
|
||||
|
@ -629,9 +622,8 @@ public class GpodnetService {
|
|||
|
||||
private List<GpodnetPodcast> readPodcastListFromJSONArray(JSONArray array)
|
||||
throws JSONException {
|
||||
if (array == null) {
|
||||
throw new IllegalArgumentException("array must not be null");
|
||||
}
|
||||
Validate.notNull(array);
|
||||
|
||||
List<GpodnetPodcast> result = new ArrayList<GpodnetPodcast>(
|
||||
array.length());
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
|
@ -685,9 +677,8 @@ public class GpodnetService {
|
|||
|
||||
private List<GpodnetDevice> readDeviceListFromJSONArray(JSONArray array)
|
||||
throws JSONException {
|
||||
if (array == null) {
|
||||
throw new IllegalArgumentException("array must not be null");
|
||||
}
|
||||
Validate.notNull(array);
|
||||
|
||||
List<GpodnetDevice> result = new ArrayList<GpodnetDevice>(
|
||||
array.length());
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
|
@ -707,9 +698,8 @@ public class GpodnetService {
|
|||
|
||||
private GpodnetSubscriptionChange readSubscriptionChangesFromJSONObject(
|
||||
JSONObject object) throws JSONException {
|
||||
if (object == null) {
|
||||
throw new IllegalArgumentException("object must not be null");
|
||||
}
|
||||
Validate.notNull(object);
|
||||
|
||||
List<String> added = new LinkedList<String>();
|
||||
JSONArray jsonAdded = object.getJSONArray("add");
|
||||
for (int i = 0; i < jsonAdded.length(); i++) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.gpoddernet.model;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class GpodnetDevice {
|
||||
|
||||
private String id;
|
||||
|
@ -9,9 +11,7 @@ public class GpodnetDevice {
|
|||
|
||||
public GpodnetDevice(String id, String caption, String type,
|
||||
int subscriptions) {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("ID must not be null");
|
||||
}
|
||||
Validate.notNull(id);
|
||||
|
||||
this.id = id;
|
||||
this.caption = caption;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.gpoddernet.model;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class GpodnetPodcast {
|
||||
private String url;
|
||||
private String title;
|
||||
|
@ -11,10 +13,9 @@ public class GpodnetPodcast {
|
|||
|
||||
public GpodnetPodcast(String url, String title, String description,
|
||||
int subscribers, String logoUrl, String website, String mygpoLink) {
|
||||
if (url == null || title == null || description == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"URL, title and description must not be null");
|
||||
}
|
||||
Validate.notNull(url);
|
||||
Validate.notNull(title);
|
||||
Validate.notNull(description);
|
||||
|
||||
this.url = url;
|
||||
this.title = title;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.gpoddernet.model;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GpodnetSubscriptionChange {
|
||||
|
@ -9,10 +11,9 @@ public class GpodnetSubscriptionChange {
|
|||
|
||||
public GpodnetSubscriptionChange(List<String> added, List<String> removed,
|
||||
long timestamp) {
|
||||
if (added == null || removed == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"added and remove must not be null");
|
||||
}
|
||||
Validate.notNull(added);
|
||||
Validate.notNull(removed);
|
||||
|
||||
this.added = added;
|
||||
this.removed = removed;
|
||||
this.timestamp = timestamp;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.gpoddernet.model;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class GpodnetTag {
|
||||
|
@ -8,9 +10,7 @@ public class GpodnetTag {
|
|||
private int usage;
|
||||
|
||||
public GpodnetTag(String name, int usage) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Name must not be null");
|
||||
}
|
||||
Validate.notNull(name);
|
||||
|
||||
this.name = name;
|
||||
this.usage = usage;
|
||||
|
|
|
@ -4,6 +4,9 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
|
||||
/**
|
||||
|
@ -66,8 +69,8 @@ public class PlaybackPreferences implements
|
|||
public static void createInstance(Context context) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Creating new instance of UserPreferences");
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException("Context must not be null");
|
||||
Validate.notNull(context);
|
||||
|
||||
instance = new PlaybackPreferences(context);
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
|
|
@ -12,6 +12,7 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.receiver.FeedUpdateReceiver;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
|
@ -92,8 +93,8 @@ public class UserPreferences implements
|
|||
public static void createInstance(Context context) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Creating new instance of UserPreferences");
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException("Context must not be null");
|
||||
Validate.notNull(context);
|
||||
|
||||
instance = new UserPreferences(context);
|
||||
|
||||
createImportDirectory();
|
||||
|
|
|
@ -4,6 +4,9 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
|
@ -15,10 +18,10 @@ public class AlarmUpdateReceiver extends BroadcastReceiver {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received intent");
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
if (StringUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Resetting update alarm after reboot");
|
||||
} else if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
} else if (StringUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Resetting update alarm after app upgrade");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import android.content.Intent;
|
|||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.storage.DBTasks;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
|
@ -16,7 +19,7 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
if (StringUtils.equals(intent.getAction(), ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received intent");
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ import android.content.Intent;
|
|||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBTasks;
|
||||
|
@ -17,7 +20,7 @@ public class FeedUpdateReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ACTION_REFRESH_FEEDS)) {
|
||||
if (StringUtils.equals(intent.getAction(), ACTION_REFRESH_FEEDS)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received intent");
|
||||
boolean mobileUpdate = UserPreferences.isAllowMobileUpdate();
|
||||
|
|
|
@ -5,6 +5,9 @@ import android.appwidget.AppWidgetProvider;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.service.playback.PlayerWidgetService;
|
||||
|
||||
|
@ -15,9 +18,9 @@ public class PlayerWidget extends AppWidgetProvider {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(FORCE_WIDGET_UPDATE)) {
|
||||
if (StringUtils.equals(intent.getAction(), FORCE_WIDGET_UPDATE)) {
|
||||
startUpdate(context);
|
||||
} else if (intent.getAction().equals(STOP_WIDGET_UPDATE)) {
|
||||
} else if (StringUtils.equals(intent.getAction(), STOP_WIDGET_UPDATE)) {
|
||||
stopUpdate(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package de.danoeh.antennapod.service.download;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class DownloadRequest implements Parcelable {
|
||||
|
||||
private final String destination;
|
||||
|
@ -21,15 +23,9 @@ public class DownloadRequest implements Parcelable {
|
|||
|
||||
public DownloadRequest(String destination, String source, String title,
|
||||
long feedfileId, int feedfileType, String username, String password, boolean deleteOnFailure) {
|
||||
if (destination == null) {
|
||||
throw new IllegalArgumentException("Destination must not be null");
|
||||
}
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("Source must not be null");
|
||||
}
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException("Title must not be null");
|
||||
}
|
||||
Validate.notNull(destination);
|
||||
Validate.notNull(source);
|
||||
Validate.notNull(title);
|
||||
|
||||
this.destination = destination;
|
||||
this.source = source;
|
||||
|
@ -110,11 +106,14 @@ public class DownloadRequest implements Parcelable {
|
|||
if (size != that.size) return false;
|
||||
if (soFar != that.soFar) return false;
|
||||
if (statusMsg != that.statusMsg) return false;
|
||||
if (destination != null ? !destination.equals(that.destination) : that.destination != null) return false;
|
||||
if (password != null ? !password.equals(that.password) : that.password != null) return false;
|
||||
if (destination != null ? !destination.equals(that.destination) : that.destination != null)
|
||||
return false;
|
||||
if (password != null ? !password.equals(that.password) : that.password != null)
|
||||
return false;
|
||||
if (source != null ? !source.equals(that.source) : that.source != null) return false;
|
||||
if (title != null ? !title.equals(that.title) : that.title != null) return false;
|
||||
if (username != null ? !username.equals(that.username) : that.username != null) return false;
|
||||
if (username != null ? !username.equals(that.username) : that.username != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import de.danoeh.antennapod.util.DownloadError;
|
|||
import de.danoeh.antennapod.util.InvalidFeedException;
|
||||
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;
|
||||
|
||||
|
@ -394,12 +395,10 @@ public class DownloadService extends Service {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ACTION_CANCEL_DOWNLOAD)) {
|
||||
if (StringUtils.equals(intent.getAction(), ACTION_CANCEL_DOWNLOAD)) {
|
||||
String url = intent.getStringExtra(EXTRA_DOWNLOAD_URL);
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"ACTION_CANCEL_DOWNLOAD intent needs download url extra");
|
||||
}
|
||||
Validate.notNull(url, "ACTION_CANCEL_DOWNLOAD intent needs download url extra");
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Cancelling download with url " + url);
|
||||
Downloader d = getDownloader(url);
|
||||
|
@ -409,7 +408,7 @@ public class DownloadService extends Service {
|
|||
Log.e(TAG, "Could not cancel download with url " + url);
|
||||
}
|
||||
|
||||
} else if (intent.getAction().equals(ACTION_CANCEL_ALL_DOWNLOADS)) {
|
||||
} else if (StringUtils.equals(intent.getAction(), ACTION_CANCEL_ALL_DOWNLOADS)) {
|
||||
for (Downloader d : downloads) {
|
||||
d.cancel();
|
||||
if (BuildConfig.DEBUG)
|
||||
|
@ -1033,12 +1032,9 @@ public class DownloadService extends Service {
|
|||
private DownloadStatus status;
|
||||
|
||||
public ImageHandlerThread(DownloadStatus status, DownloadRequest request) {
|
||||
if (status == null) {
|
||||
throw new IllegalArgumentException("Status must not be null");
|
||||
}
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("Request must not be null");
|
||||
}
|
||||
Validate.notNull(status);
|
||||
Validate.notNull(request);
|
||||
|
||||
this.status = status;
|
||||
this.request = request;
|
||||
}
|
||||
|
@ -1070,12 +1066,8 @@ public class DownloadService extends Service {
|
|||
private DownloadStatus status;
|
||||
|
||||
public MediaHandlerThread(DownloadStatus status, DownloadRequest request) {
|
||||
if (status == null) {
|
||||
throw new IllegalArgumentException("Status must not be null");
|
||||
}
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("Request must not be null");
|
||||
}
|
||||
Validate.notNull(status);
|
||||
Validate.notNull(request);
|
||||
|
||||
this.status = status;
|
||||
this.request = request;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.service.download;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.feed.FeedFile;
|
||||
import de.danoeh.antennapod.util.DownloadError;
|
||||
|
||||
|
@ -59,9 +61,8 @@ public class DownloadStatus {
|
|||
|
||||
public DownloadStatus(DownloadRequest request, DownloadError reason,
|
||||
boolean successful, boolean cancelled, String reasonDetailed) {
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("request must not be null");
|
||||
}
|
||||
Validate.notNull(request);
|
||||
|
||||
this.title = request.getTitle();
|
||||
this.feedfileId = request.getFeedfileId();
|
||||
this.feedfileType = request.getFeedfileType();
|
||||
|
@ -75,9 +76,7 @@ public class DownloadStatus {
|
|||
/** Constructor for creating new completed downloads. */
|
||||
public DownloadStatus(FeedFile feedfile, String title, DownloadError reason,
|
||||
boolean successful, String reasonDetailed) {
|
||||
if (feedfile == null) {
|
||||
throw new IllegalArgumentException("feedfile must not be null");
|
||||
}
|
||||
Validate.notNull(feedfile);
|
||||
|
||||
this.title = title;
|
||||
this.done = true;
|
||||
|
|
|
@ -23,6 +23,9 @@ import android.util.Pair;
|
|||
import android.view.KeyEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
|
@ -896,8 +899,7 @@ public class PlaybackService extends Service {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction() != null &&
|
||||
intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
|
||||
if (StringUtils.equals(intent.getAction(), Intent.ACTION_HEADSET_PLUG)) {
|
||||
int state = intent.getIntExtra("state", -1);
|
||||
if (state != -1) {
|
||||
if (BuildConfig.DEBUG)
|
||||
|
@ -939,8 +941,7 @@ public class PlaybackService extends Service {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction() != null &&
|
||||
intent.getAction().equals(ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
|
||||
if (StringUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
|
@ -950,8 +951,7 @@ public class PlaybackService extends Service {
|
|||
private BroadcastReceiver skipCurrentEpisodeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction() != null &&
|
||||
intent.getAction().equals(ACTION_SKIP_CURRENT_EPISODE)) {
|
||||
if (StringUtils.equals(intent.getAction(), ACTION_SKIP_CURRENT_EPISODE)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received SKIP_CURRENT_EPISODE intent");
|
||||
mediaPlayer.endPlayback();
|
||||
|
|
|
@ -7,6 +7,9 @@ import android.media.RemoteControlClient;
|
|||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.feed.Chapter;
|
||||
import de.danoeh.antennapod.feed.MediaType;
|
||||
|
@ -61,10 +64,8 @@ public class PlaybackServiceMediaPlayer {
|
|||
private final ThreadPoolExecutor executor;
|
||||
|
||||
public PlaybackServiceMediaPlayer(Context context, PSMPCallback callback) {
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException("context = null");
|
||||
if (callback == null)
|
||||
throw new IllegalArgumentException("callback = null");
|
||||
Validate.notNull(context);
|
||||
Validate.notNull(callback);
|
||||
|
||||
this.context = context;
|
||||
this.callback = callback;
|
||||
|
@ -115,8 +116,8 @@ public class PlaybackServiceMediaPlayer {
|
|||
* @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) {
|
||||
if (playable == null)
|
||||
throw new IllegalArgumentException("playable = null");
|
||||
Validate.notNull(playable);
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Play media object.");
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
|
@ -142,8 +143,7 @@ public class PlaybackServiceMediaPlayer {
|
|||
* @see #playMediaObject(de.danoeh.antennapod.util.playback.Playable, boolean, boolean, boolean)
|
||||
*/
|
||||
private void playMediaObject(final Playable playable, final boolean forceReset, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) {
|
||||
if (playable == null)
|
||||
throw new IllegalArgumentException("playable = null");
|
||||
Validate.notNull(playable);
|
||||
if (!playerLock.isHeldByCurrentThread())
|
||||
throw new IllegalStateException("method requires playerLock");
|
||||
|
||||
|
@ -458,8 +458,8 @@ public class PlaybackServiceMediaPlayer {
|
|||
* Seek to the start of the specified chapter.
|
||||
*/
|
||||
public void seekToChapter(Chapter c) {
|
||||
if (c == null)
|
||||
throw new IllegalArgumentException("c = null");
|
||||
Validate.notNull(c);
|
||||
|
||||
seekTo((int) c.getStart());
|
||||
}
|
||||
|
||||
|
@ -662,8 +662,8 @@ public class PlaybackServiceMediaPlayer {
|
|||
* @param newMedia The new playable object of the PSMP object. This can be null.
|
||||
*/
|
||||
private synchronized void setPlayerStatus(PlayerStatus newStatus, Playable newMedia) {
|
||||
if (newStatus == null)
|
||||
throw new IllegalArgumentException("newStatus = null");
|
||||
Validate.notNull(newStatus);
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Setting player status to " + newStatus);
|
||||
|
||||
this.playerStatus = newStatus;
|
||||
|
|
|
@ -2,6 +2,9 @@ package de.danoeh.antennapod.service.playback;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
|
@ -52,10 +55,8 @@ public class PlaybackServiceTaskManager {
|
|||
* @param callback A PSTMCallback object for notifying the user about updates. Must not be null.
|
||||
*/
|
||||
public PlaybackServiceTaskManager(Context context, PSTMCallback callback) {
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException("context must not be null");
|
||||
if (callback == null)
|
||||
throw new IllegalArgumentException("callback must not be null");
|
||||
Validate.notNull(context);
|
||||
Validate.notNull(callback);
|
||||
|
||||
this.context = context;
|
||||
this.callback = callback;
|
||||
|
@ -195,8 +196,7 @@ public class PlaybackServiceTaskManager {
|
|||
* @throws java.lang.IllegalArgumentException if waitingTime <= 0
|
||||
*/
|
||||
public synchronized void setSleepTimer(long waitingTime) {
|
||||
if (waitingTime <= 0)
|
||||
throw new IllegalArgumentException("waitingTime <= 0");
|
||||
Validate.isTrue(waitingTime > 0, "Waiting time <= 0");
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Setting sleep timer to " + Long.toString(waitingTime)
|
||||
|
@ -271,8 +271,7 @@ public class PlaybackServiceTaskManager {
|
|||
* On completion, the callback's onChapterLoaded method will be called.
|
||||
*/
|
||||
public synchronized void startChapterLoader(final Playable media) {
|
||||
if (media == null)
|
||||
throw new IllegalArgumentException("media = null");
|
||||
Validate.notNull(media);
|
||||
|
||||
if (isChapterLoaderActive()) {
|
||||
cancelChapterLoader();
|
||||
|
|
|
@ -5,6 +5,9 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.receiver.SPAReceiver;
|
||||
|
||||
|
@ -56,7 +59,7 @@ public class SPAUtil {
|
|||
*/
|
||||
public static void resetSPAPreferences(Context c) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (c == null) throw new IllegalArgumentException("c = null");
|
||||
Validate.notNull(c);
|
||||
SharedPreferences.Editor editor = PreferenceManager
|
||||
.getDefaultSharedPreferences(c.getApplicationContext()).edit();
|
||||
editor.putBoolean(PREF_HAS_QUERIED_SP_APPS, false);
|
||||
|
|
|
@ -14,6 +14,7 @@ import de.danoeh.antennapod.util.URLChecker;
|
|||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
@ -57,8 +58,9 @@ public class DownloadRequester {
|
|||
* @return True if the download request was accepted, false otherwise.
|
||||
*/
|
||||
public boolean download(Context context, DownloadRequest request) {
|
||||
if (context == null) throw new IllegalArgumentException("context = null");
|
||||
if (request == null) throw new IllegalArgumentException("request = null");
|
||||
Validate.notNull(context);
|
||||
Validate.notNull(request);
|
||||
|
||||
if (downloads.containsKey(request.getSource())) {
|
||||
if (BuildConfig.DEBUG) Log.i(TAG, "DownloadRequest is already stored.");
|
||||
return false;
|
||||
|
|
|
@ -10,14 +10,23 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.feed.*;
|
||||
import de.danoeh.antennapod.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.util.flattr.FlattrStatus;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.feed.Chapter;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedComponent;
|
||||
import de.danoeh.antennapod.feed.FeedImage;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.util.flattr.FlattrStatus;
|
||||
|
||||
// TODO Remove media column from feeditem table
|
||||
|
||||
/**
|
||||
|
@ -1024,9 +1033,8 @@ public class PodDBAdapter {
|
|||
* @throws IllegalArgumentException if limit < 0
|
||||
*/
|
||||
public final Cursor getCompletedMediaCursor(int limit) {
|
||||
if (limit < 0) {
|
||||
throw new IllegalArgumentException("Limit must be >= 0");
|
||||
}
|
||||
Validate.isTrue(limit >= 0, "Limit must be >= 0");
|
||||
|
||||
Cursor c = db.query(TABLE_NAME_FEED_MEDIA, null,
|
||||
KEY_PLAYBACK_COMPLETION_DATE + " > 0 LIMIT " + limit, null, null,
|
||||
null, null);
|
||||
|
|
|
@ -12,6 +12,7 @@ import de.danoeh.antennapod.feed.MediaType;
|
|||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.util.ShownotesProvider;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -216,9 +217,8 @@ public interface Playable extends Parcelable,
|
|||
private Playable playable;
|
||||
|
||||
public DefaultPlayableImageLoader(Playable playable) {
|
||||
if (playable == null) {
|
||||
throw new IllegalArgumentException("Playable must not be null");
|
||||
}
|
||||
Validate.notNull(playable);
|
||||
|
||||
this.playable = playable;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ import android.view.View.OnClickListener;
|
|||
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 de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.Chapter;
|
||||
|
@ -62,8 +66,8 @@ public abstract class PlaybackController {
|
|||
private boolean reinitOnPause;
|
||||
|
||||
public PlaybackController(Activity activity, boolean reinitOnPause) {
|
||||
if (activity == null)
|
||||
throw new IllegalArgumentException("activity = null");
|
||||
Validate.notNull(activity);
|
||||
|
||||
this.activity = activity;
|
||||
this.reinitOnPause = reinitOnPause;
|
||||
schedExecutor = new ScheduledThreadPoolExecutor(SCHED_EX_POOLSIZE,
|
||||
|
@ -360,7 +364,7 @@ public abstract class PlaybackController {
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (isConnectedToPlaybackService()) {
|
||||
if (intent.getAction().equals(
|
||||
if (StringUtils.equals(intent.getAction(),
|
||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
|
||||
release();
|
||||
onShutdownNotification();
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.res.TypedArray;
|
|||
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;
|
||||
|
@ -154,7 +155,7 @@ public class Timeline {
|
|||
|
||||
|
||||
public void setShownotesProvider(ShownotesProvider shownotesProvider) {
|
||||
if (shownotesProvider == null) throw new IllegalArgumentException("shownotesProvider = null");
|
||||
Validate.notNull(shownotesProvider);
|
||||
this.shownotesProvider = shownotesProvider;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue