diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-07-06 13:48:38 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-07-06 13:48:38 +0200 |
commit | fb1fcb06005e925f6c1ebabeb1f31007bc86a48c (patch) | |
tree | cce2db2e3d59b35ed138fe7c22448cf657ee75c5 /src/de/danoeh/antennapod/adapter | |
parent | 60214f6306bfed6b870b8cc5c8ce0b08d4590cdd (diff) | |
download | AntennaPod-fb1fcb06005e925f6c1ebabeb1f31007bc86a48c.zip |
Increased use of library methods
Diffstat (limited to 'src/de/danoeh/antennapod/adapter')
-rw-r--r-- | src/de/danoeh/antennapod/adapter/ActionButtonUtils.java | 9 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java b/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java index 17c61a86c..4308f4f2c 100644 --- a/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java +++ b/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java @@ -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); diff --git a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index 3acd587af..801cd1e12 100644 --- a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -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; } |