Use IllegalArgumentException, not InvalidParameterException

Because IllegalArgumentException is the standard one.

Change-Id: Ib4d0bfa88a3d4218148a7cb248d9baa2124a72ba
This commit is contained in:
Makoto Onuki 2011-05-16 17:29:13 -07:00
parent 7e1fa63d75
commit 54c91f00d7
12 changed files with 18 additions and 36 deletions

View File

@ -31,8 +31,6 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns, Parcelable { public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns, Parcelable {
public static final String TABLE_NAME = "Mailbox"; public static final String TABLE_NAME = "Mailbox";
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
@ -407,7 +405,7 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
*/ */
public static boolean canMoveFrom(Context context, long mailboxId) { public static boolean canMoveFrom(Context context, long mailboxId) {
if (mailboxId < 0) { if (mailboxId < 0) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
Uri url = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId); Uri url = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId);
int type = Utility.getFirstRowInt(context, url, MAILBOX_TYPE_PROJECTION, int type = Utility.getFirstRowInt(context, url, MAILBOX_TYPE_PROJECTION,

View File

@ -58,7 +58,6 @@ import android.util.Log;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@ -797,7 +796,7 @@ public class Controller {
public EmailAsyncTask<Void, Void, Void> moveMessages(final long[] messageIds, public EmailAsyncTask<Void, Void, Void> moveMessages(final long[] messageIds,
final long newMailboxId) { final long newMailboxId) {
if (messageIds == null || messageIds.length == 0) { if (messageIds == null || messageIds.length == 0) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
return EmailAsyncTask.runAsyncParallel(new Runnable() { return EmailAsyncTask.runAsyncParallel(new Runnable() {
public void run() { public void run() {

View File

@ -24,7 +24,6 @@ import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -194,14 +193,14 @@ public class RefreshManager {
public void registerListener(Listener listener) { public void registerListener(Listener listener) {
if (listener == null) { if (listener == null) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
mListeners.add(listener); mListeners.add(listener);
} }
public void unregisterListener(Listener listener) { public void unregisterListener(Listener listener) {
if (listener == null) { if (listener == null) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
mListeners.remove(listener); mListeners.remove(listener);
} }

View File

@ -21,7 +21,6 @@ import com.android.emailcommon.Logging;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -84,7 +83,7 @@ public class Throttle {
/* package */ Throttle(String name, Runnable callback, Handler handler,int minTimeout, /* package */ Throttle(String name, Runnable callback, Handler handler,int minTimeout,
int maxTimeout, Clock clock, Timer timer) { int maxTimeout, Clock clock, Timer timer) {
if (maxTimeout < minTimeout) { if (maxTimeout < minTimeout) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
mName = name; mName = name;
mCallback = callback; mCallback = callback;

View File

@ -50,7 +50,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -113,7 +112,7 @@ public class EmailActivity extends Activity implements View.OnClickListener {
public static Intent createOpenMailboxIntent(Activity fromActivity, long accountId, public static Intent createOpenMailboxIntent(Activity fromActivity, long accountId,
long mailboxId) { long mailboxId) {
if (accountId == -1 || mailboxId == -1) { if (accountId == -1 || mailboxId == -1) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class); Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class);
i.putExtra(EXTRA_ACCOUNT_ID, accountId); 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, public static Intent createOpenMessageIntent(Activity fromActivity, long accountId,
long mailboxId, long messageId) { long mailboxId, long messageId) {
if (accountId == -1 || mailboxId == -1 || messageId == -1) { if (accountId == -1 || mailboxId == -1 || messageId == -1) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class); Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class);
i.putExtra(EXTRA_ACCOUNT_ID, accountId); i.putExtra(EXTRA_ACCOUNT_ID, accountId);

View File

@ -52,7 +52,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView; import android.widget.ListView;
import java.security.InvalidParameterException;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -218,7 +217,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
*/ */
public static MailboxListFragment newInstance(long accountId, long parentMailboxId) { public static MailboxListFragment newInstance(long accountId, long parentMailboxId) {
if (accountId == Account.PSEUDO_ACCOUNT_ID_NONE) { if (accountId == Account.PSEUDO_ACCOUNT_ID_NONE) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
final MailboxListFragment instance = new MailboxListFragment(); final MailboxListFragment instance = new MailboxListFragment();
final Bundle args = new Bundle(); final Bundle args = new Bundle();

View File

@ -27,8 +27,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
/** /**
* A {@link MessageViewFragmentBase} subclass for file based messages. (aka EML files) * A {@link MessageViewFragmentBase} subclass for file based messages. (aka EML files)
*/ */
@ -84,7 +82,7 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
throw new IllegalStateException(); throw new IllegalStateException();
} }
if (fileEmailUri == null) { if (fileEmailUri == null) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
mFileEmailUri = fileEmailUri; mFileEmailUri = fileEmailUri;
} }

View File

@ -69,7 +69,6 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.security.InvalidParameterException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -249,17 +248,17 @@ public class MessageListFragment extends ListFragment
public static MessageListFragment newInstance(long accountId, long mailboxId) { public static MessageListFragment newInstance(long accountId, long mailboxId) {
// sanity check // sanity check
if ((accountId == Account.PSEUDO_ACCOUNT_ID_NONE) || (mailboxId == Mailbox.NO_MAILBOX)) { if ((accountId == Account.PSEUDO_ACCOUNT_ID_NONE) || (mailboxId == Mailbox.NO_MAILBOX)) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
if (accountId == Account.ACCOUNT_ID_COMBINED_VIEW) { if (accountId == Account.ACCOUNT_ID_COMBINED_VIEW) {
// must be a combined mailbox. // must be a combined mailbox.
if (mailboxId >= 0) { if (mailboxId >= 0) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
} else { } else {
// must be a regular mailbox. // must be a regular mailbox.
if (mailboxId <= 0) { if (mailboxId <= 0) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
} }
final MessageListFragment instance = new MessageListFragment(); final MessageListFragment instance = new MessageListFragment();

View File

@ -41,8 +41,6 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import java.security.InvalidParameterException;
/** /**
* A {@link MessageViewFragmentBase} subclass for regular email messages. (regular as in "not eml * A {@link MessageViewFragmentBase} subclass for regular email messages. (regular as in "not eml
* files"). * files").
@ -139,7 +137,7 @@ public class MessageViewFragment extends MessageViewFragmentBase
*/ */
public static MessageViewFragment newInstance(long messageId) { public static MessageViewFragment newInstance(long messageId) {
if (messageId == -1) { if (messageId == -1) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
final MessageViewFragment instance = new MessageViewFragment(); final MessageViewFragment instance = new MessageViewFragment();
final Bundle args = new Bundle(); final Bundle args = new Bundle();

View File

@ -39,8 +39,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
/** /**
* "Move (messages) to" dialog. * "Move (messages) to" dialog.
* *
@ -79,7 +77,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa
public static <T extends Fragment & Callback> MoveMessageToDialog newInstance(long[] messageIds, public static <T extends Fragment & Callback> MoveMessageToDialog newInstance(long[] messageIds,
T callbackFragment) { T callbackFragment) {
if (messageIds.length == 0) { if (messageIds.length == 0) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
if (callbackFragment == null) { if (callbackFragment == null) {
throw new IllegalArgumentException(); // fail fast throw new IllegalArgumentException(); // fail fast

View File

@ -29,14 +29,12 @@ import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.emailcommon.utility.Utility; import com.android.emailcommon.utility.Utility;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import java.security.InvalidParameterException;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
@ -679,7 +677,7 @@ class UIControllerTwoPane extends UIControllerBase implements
} }
preFragmentTransactionCheck(); preFragmentTransactionCheck();
if (accountId == NO_ACCOUNT) { if (accountId == NO_ACCOUNT) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
// TODO Check if the current fragment has been initialized with the same parameters, and // TODO Check if the current fragment has been initialized with the same parameters, and
@ -734,7 +732,7 @@ class UIControllerTwoPane extends UIControllerBase implements
} }
preFragmentTransactionCheck(); preFragmentTransactionCheck();
if (mailboxId == 0 || mailboxId == -1) { 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 // TODO Check if the current fragment has been initialized with the same parameters, and
@ -772,7 +770,7 @@ class UIControllerTwoPane extends UIControllerBase implements
} }
preFragmentTransactionCheck(); preFragmentTransactionCheck();
if (messageId == NO_MESSAGE) { if (messageId == NO_MESSAGE) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
// TODO Check if the current fragment has been initialized with the same parameters, and // TODO Check if the current fragment has been initialized with the same parameters, and

View File

@ -23,8 +23,6 @@ import com.android.emailcommon.provider.Mailbox;
import android.content.AsyncTaskLoader; import android.content.AsyncTaskLoader;
import android.content.Context; import android.content.Context;
import java.security.InvalidParameterException;
/** /**
* Loader to load {@link Mailbox} and {@link Account}. * Loader to load {@link Mailbox} and {@link Account}.
@ -55,7 +53,7 @@ public class MailboxAccountLoader extends AsyncTaskLoader<MailboxAccountLoader.R
public MailboxAccountLoader(Context context, long mailboxId) { public MailboxAccountLoader(Context context, long mailboxId) {
super(context); super(context);
if (mailboxId == -1) { if (mailboxId == -1) {
throw new InvalidParameterException(); throw new IllegalArgumentException();
} }
mContext = context; mContext = context;
mMailboxId = mailboxId; mMailboxId = mailboxId;