From 54c91f00d7f967690a80b992062e75c40182d088 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 16 May 2011 17:29:13 -0700 Subject: [PATCH] Use IllegalArgumentException, not InvalidParameterException Because IllegalArgumentException is the standard one. Change-Id: Ib4d0bfa88a3d4218148a7cb248d9baa2124a72ba --- .../src/com/android/emailcommon/provider/Mailbox.java | 4 +--- src/com/android/email/Controller.java | 3 +-- src/com/android/email/RefreshManager.java | 5 ++--- src/com/android/email/Throttle.java | 3 +-- src/com/android/email/activity/EmailActivity.java | 5 ++--- src/com/android/email/activity/MailboxListFragment.java | 3 +-- .../android/email/activity/MessageFileViewFragment.java | 4 +--- src/com/android/email/activity/MessageListFragment.java | 7 +++---- src/com/android/email/activity/MessageViewFragment.java | 4 +--- src/com/android/email/activity/MoveMessageToDialog.java | 4 +--- src/com/android/email/activity/UIControllerTwoPane.java | 8 +++----- src/com/android/email/data/MailboxAccountLoader.java | 4 +--- 12 files changed, 18 insertions(+), 36 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java index e9f910bab..3d10fb6cb 100644 --- a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java +++ b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java @@ -31,8 +31,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; -import java.security.InvalidParameterException; - public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns, Parcelable { public static final String TABLE_NAME = "Mailbox"; @SuppressWarnings("hiding") @@ -407,7 +405,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns */ public static boolean canMoveFrom(Context context, long mailboxId) { if (mailboxId < 0) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } Uri url = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId); int type = Utility.getFirstRowInt(context, url, MAILBOX_TYPE_PROJECTION, diff --git a/src/com/android/email/Controller.java b/src/com/android/email/Controller.java index 1b6174f23..850ef9a94 100644 --- a/src/com/android/email/Controller.java +++ b/src/com/android/email/Controller.java @@ -58,7 +58,6 @@ import android.util.Log; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -797,7 +796,7 @@ public class Controller { public EmailAsyncTask moveMessages(final long[] messageIds, final long newMailboxId) { if (messageIds == null || messageIds.length == 0) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } return EmailAsyncTask.runAsyncParallel(new Runnable() { public void run() { diff --git a/src/com/android/email/RefreshManager.java b/src/com/android/email/RefreshManager.java index 986a55dbd..67b732b7e 100644 --- a/src/com/android/email/RefreshManager.java +++ b/src/com/android/email/RefreshManager.java @@ -24,7 +24,6 @@ import android.content.Context; import android.os.Handler; import android.util.Log; -import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -194,14 +193,14 @@ public class RefreshManager { public void registerListener(Listener listener) { if (listener == null) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } mListeners.add(listener); } public void unregisterListener(Listener listener) { if (listener == null) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } mListeners.remove(listener); } diff --git a/src/com/android/email/Throttle.java b/src/com/android/email/Throttle.java index 41e22e1b9..9edddf141 100644 --- a/src/com/android/email/Throttle.java +++ b/src/com/android/email/Throttle.java @@ -21,7 +21,6 @@ import com.android.emailcommon.Logging; import android.os.Handler; import android.util.Log; -import java.security.InvalidParameterException; import java.util.Timer; import java.util.TimerTask; @@ -84,7 +83,7 @@ public class Throttle { /* package */ Throttle(String name, Runnable callback, Handler handler,int minTimeout, int maxTimeout, Clock clock, Timer timer) { if (maxTimeout < minTimeout) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } mName = name; mCallback = callback; diff --git a/src/com/android/email/activity/EmailActivity.java b/src/com/android/email/activity/EmailActivity.java index 624beb201..dd4619d84 100644 --- a/src/com/android/email/activity/EmailActivity.java +++ b/src/com/android/email/activity/EmailActivity.java @@ -50,7 +50,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; -import java.security.InvalidParameterException; import java.util.ArrayList; /** @@ -113,7 +112,7 @@ public class EmailActivity extends Activity implements View.OnClickListener { public static Intent createOpenMailboxIntent(Activity fromActivity, long accountId, long mailboxId) { if (accountId == -1 || mailboxId == -1) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class); i.putExtra(EXTRA_ACCOUNT_ID, accountId); @@ -132,7 +131,7 @@ public class EmailActivity extends Activity implements View.OnClickListener { public static Intent createOpenMessageIntent(Activity fromActivity, long accountId, long mailboxId, long messageId) { if (accountId == -1 || mailboxId == -1 || messageId == -1) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class); i.putExtra(EXTRA_ACCOUNT_ID, accountId); diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java index 0be590a25..8101271fc 100644 --- a/src/com/android/email/activity/MailboxListFragment.java +++ b/src/com/android/email/activity/MailboxListFragment.java @@ -52,7 +52,6 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; -import java.security.InvalidParameterException; import java.util.Timer; import java.util.TimerTask; @@ -218,7 +217,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList */ public static MailboxListFragment newInstance(long accountId, long parentMailboxId) { if (accountId == Account.PSEUDO_ACCOUNT_ID_NONE) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } final MailboxListFragment instance = new MailboxListFragment(); final Bundle args = new Bundle(); diff --git a/src/com/android/email/activity/MessageFileViewFragment.java b/src/com/android/email/activity/MessageFileViewFragment.java index 81a97afe8..8f6463eca 100644 --- a/src/com/android/email/activity/MessageFileViewFragment.java +++ b/src/com/android/email/activity/MessageFileViewFragment.java @@ -27,8 +27,6 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; -import java.security.InvalidParameterException; - /** * A {@link MessageViewFragmentBase} subclass for file based messages. (aka EML files) */ @@ -84,7 +82,7 @@ public class MessageFileViewFragment extends MessageViewFragmentBase { throw new IllegalStateException(); } if (fileEmailUri == null) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } mFileEmailUri = fileEmailUri; } diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index 476e24417..b7da8c662 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -69,7 +69,6 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; -import java.security.InvalidParameterException; import java.util.HashSet; import java.util.Set; @@ -249,17 +248,17 @@ public class MessageListFragment extends ListFragment public static MessageListFragment newInstance(long accountId, long mailboxId) { // sanity check if ((accountId == Account.PSEUDO_ACCOUNT_ID_NONE) || (mailboxId == Mailbox.NO_MAILBOX)) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } if (accountId == Account.ACCOUNT_ID_COMBINED_VIEW) { // must be a combined mailbox. if (mailboxId >= 0) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } } else { // must be a regular mailbox. if (mailboxId <= 0) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } } final MessageListFragment instance = new MessageListFragment(); diff --git a/src/com/android/email/activity/MessageViewFragment.java b/src/com/android/email/activity/MessageViewFragment.java index 52d23e6a5..aa8310e38 100644 --- a/src/com/android/email/activity/MessageViewFragment.java +++ b/src/com/android/email/activity/MessageViewFragment.java @@ -41,8 +41,6 @@ import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; -import java.security.InvalidParameterException; - /** * A {@link MessageViewFragmentBase} subclass for regular email messages. (regular as in "not eml * files"). @@ -139,7 +137,7 @@ public class MessageViewFragment extends MessageViewFragmentBase */ public static MessageViewFragment newInstance(long messageId) { if (messageId == -1) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } final MessageViewFragment instance = new MessageViewFragment(); final Bundle args = new Bundle(); diff --git a/src/com/android/email/activity/MoveMessageToDialog.java b/src/com/android/email/activity/MoveMessageToDialog.java index 169dd36e2..59a312631 100644 --- a/src/com/android/email/activity/MoveMessageToDialog.java +++ b/src/com/android/email/activity/MoveMessageToDialog.java @@ -39,8 +39,6 @@ import android.os.Bundle; import android.os.Handler; import android.util.Log; -import java.security.InvalidParameterException; - /** * "Move (messages) to" dialog. * @@ -79,7 +77,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa public static MoveMessageToDialog newInstance(long[] messageIds, T callbackFragment) { if (messageIds.length == 0) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } if (callbackFragment == null) { throw new IllegalArgumentException(); // fail fast diff --git a/src/com/android/email/activity/UIControllerTwoPane.java b/src/com/android/email/activity/UIControllerTwoPane.java index bbe9fa274..6532841c1 100644 --- a/src/com/android/email/activity/UIControllerTwoPane.java +++ b/src/com/android/email/activity/UIControllerTwoPane.java @@ -29,14 +29,12 @@ import com.android.emailcommon.utility.EmailAsyncTask; import com.android.emailcommon.utility.Utility; import android.app.Activity; -import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Context; import android.os.Bundle; import android.util.Log; -import java.security.InvalidParameterException; import java.util.Set; import java.util.Stack; @@ -679,7 +677,7 @@ class UIControllerTwoPane extends UIControllerBase implements } preFragmentTransactionCheck(); if (accountId == NO_ACCOUNT) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } // TODO Check if the current fragment has been initialized with the same parameters, and @@ -734,7 +732,7 @@ class UIControllerTwoPane extends UIControllerBase implements } preFragmentTransactionCheck(); if (mailboxId == 0 || mailboxId == -1) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } // TODO Check if the current fragment has been initialized with the same parameters, and @@ -772,7 +770,7 @@ class UIControllerTwoPane extends UIControllerBase implements } preFragmentTransactionCheck(); if (messageId == NO_MESSAGE) { - throw new InvalidParameterException(); + throw new IllegalArgumentException(); } // TODO Check if the current fragment has been initialized with the same parameters, and diff --git a/src/com/android/email/data/MailboxAccountLoader.java b/src/com/android/email/data/MailboxAccountLoader.java index 208495d9f..5487470b3 100644 --- a/src/com/android/email/data/MailboxAccountLoader.java +++ b/src/com/android/email/data/MailboxAccountLoader.java @@ -23,8 +23,6 @@ import com.android.emailcommon.provider.Mailbox; import android.content.AsyncTaskLoader; import android.content.Context; -import java.security.InvalidParameterException; - /** * Loader to load {@link Mailbox} and {@link Account}. @@ -55,7 +53,7 @@ public class MailboxAccountLoader extends AsyncTaskLoader