Merge "Fix NPE accessing fragment arguments"

This commit is contained in:
Todd Kennedy 2011-06-02 12:02:50 -07:00 committed by Android (Google) Code Review
commit b9afe5760c

View File

@ -52,11 +52,11 @@ import android.widget.AdapterView.OnItemClickListener;
public abstract class ShortcutPickerFragment extends ListFragment public abstract class ShortcutPickerFragment extends ListFragment
implements OnItemClickListener, LoaderCallbacks<Cursor> { implements OnItemClickListener, LoaderCallbacks<Cursor> {
/** Allow all mailboxes in the mailbox list */ /** Allow all mailboxes in the mailbox list */
public static int FILTER_ALLOW_ALL = 0x00; public static int FILTER_ALLOW_ALL = 0;
/** Only allow an account's INBOX */ /** Only allow an account's INBOX */
public static int FILTER_INBOX_ONLY = 0x01; public static int FILTER_INBOX_ONLY = 1 << 0;
/** Allow an "unread" mailbox; this is not affected by {@link #FILTER_INBOX_ONLY} */ /** Allow an "unread" mailbox; this is not affected by {@link #FILTER_INBOX_ONLY} */
public static int FILTER_ALLOW_UNREAD = 0x02; public static int FILTER_ALLOW_UNREAD = 1 << 1;
/** Fragment argument to set filter values */ /** Fragment argument to set filter values */
public static final String ARG_FILTER = "ShortcutPickerFragment.filter"; public static final String ARG_FILTER = "ShortcutPickerFragment.filter";
/** The filter values; default to allow all mailboxes */ /** The filter values; default to allow all mailboxes */
@ -87,10 +87,6 @@ public abstract class ShortcutPickerFragment extends ListFragment
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
Bundle args = getArguments();
if (args != null) {
mFilter = args.getInt(ARG_FILTER);
}
if (activity instanceof PickerCallback) { if (activity instanceof PickerCallback) {
mCallback = (PickerCallback) activity; mCallback = (PickerCallback) activity;
} }
@ -239,7 +235,7 @@ public abstract class ShortcutPickerFragment extends ListFragment
ShortcutPickerFragment fragment = new MailboxShortcutPickerFragment(); ShortcutPickerFragment fragment = new MailboxShortcutPickerFragment();
final Bundle args = new Bundle(); final Bundle args = new Bundle();
args.putParcelable(MailboxShortcutPickerFragment.ARG_ACCOUNT, account); args.putParcelable(MailboxShortcutPickerFragment.ARG_ACCOUNT, account);
args.putInt(ARG_FILTER, getArguments().getInt(ARG_FILTER)); args.putInt(ARG_FILTER, getFilter());
fragment.setArguments(args); fragment.setArguments(args);
getFragmentManager() getFragmentManager()
.beginTransaction() .beginTransaction()