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