diff --git a/src/com/android/email/activity/AccountSelectorAdapter.java b/src/com/android/email/activity/AccountSelectorAdapter.java index 3c4a2aaed..e2d88bc94 100644 --- a/src/com/android/email/activity/AccountSelectorAdapter.java +++ b/src/com/android/email/activity/AccountSelectorAdapter.java @@ -209,6 +209,12 @@ public class AccountSelectorAdapter extends CursorAdapter { return (c.getLong(c.getColumnIndex(ROW_TYPE)) == ROW_TYPE_ACCOUNT); } + public boolean isMailboxItem(int position) { + Cursor c = getCursor(); + c.moveToPosition(position); + return (c.getLong(c.getColumnIndex(ROW_TYPE)) == ROW_TYPE_MAILBOX); + } + private String getAccountDisplayName(int position) { final Cursor c = getCursor(); return c.moveToPosition(position) ? getAccountDisplayName(c) : null; diff --git a/src/com/android/email/activity/ActionBarController.java b/src/com/android/email/activity/ActionBarController.java index 2d95ea444..13e4efc8f 100644 --- a/src/com/android/email/activity/ActionBarController.java +++ b/src/com/android/email/activity/ActionBarController.java @@ -17,6 +17,7 @@ package com.android.email.activity; import com.android.email.R; +import com.android.emailcommon.Logging; import com.android.emailcommon.provider.EmailContent.Account; import com.android.emailcommon.provider.Mailbox; @@ -27,6 +28,7 @@ import android.content.Context; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; @@ -236,7 +238,7 @@ public class ActionBarController { if (mAccountsSelectorAdapter.isAccountItem(itemPosition) && itemId != mCallback.getUIAccountId()) { mCallback.onAccountSelected(itemId); - } else if (!mAccountsSelectorAdapter.isAccountItem(itemPosition)) { + } else if (mAccountsSelectorAdapter.isMailboxItem(itemPosition)) { mCallback.onMailboxSelected(itemId); // We need to update the selection, otherwise the user is unable to select the // recent folder a second time w/o first selecting another item in the spinner @@ -244,6 +246,9 @@ public class ActionBarController { if (selectedPosition != AccountSelectorAdapter.UNKNOWN_POSITION) { mActionBar.setSelectedNavigationItem(selectedPosition); } + } else { + Log.i(Logging.LOG_TAG, + "Invalid type selected in ActionBarController at index " + itemPosition); } return true; } diff --git a/src/com/android/email/activity/UIControllerOnePane.java b/src/com/android/email/activity/UIControllerOnePane.java index 3538a0cf8..8d481aa04 100644 --- a/src/com/android/email/activity/UIControllerOnePane.java +++ b/src/com/android/email/activity/UIControllerOnePane.java @@ -239,7 +239,7 @@ class UIControllerOnePane extends UIControllerBase { if (mailboxId == Mailbox.NO_MAILBOX) { showAllMailboxes(); } else { - UIControllerOnePane.this.openMailbox(getUIAccountId(), mailboxId); + openMailbox(getUIAccountId(), mailboxId); } }