1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Generalize ActionBarNavigationSpinner creation.

This commit is contained in:
Sander Bogaert 2012-07-16 15:14:27 -04:00 committed by Andrew Chen
parent 4de06915ea
commit 18748499af
3 changed files with 15 additions and 13 deletions

View File

@ -106,6 +106,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
private Context context;
private MenuItem mRefreshMenuItem;
private View mActionBarProgressView;
private ActionBarNavigationSpinner mNavigationSpinner;
class FolderListHandler extends Handler {
@ -311,13 +312,8 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(
new ActionBarNavigationSpinner(this,
new String[] {"Inbox", "Folders", "Accounts"},
new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX,
ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS,
ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS }),
this);
mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this);
actionBar.setListNavigationCallbacks(mNavigationSpinner, this);
actionBar.setSelectedNavigationItem(1);
}

View File

@ -537,7 +537,7 @@ public class MessageList
}
String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount, getTimeFormat());
//setTitle(dispString);
mNavigationSpinner.setTitle(mFolderName);
mNavigationSpinner.setSubTitle(mAccount.getEmail());
} else if (mQueryString != null) {
@ -907,11 +907,7 @@ public class MessageList
ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
mNavigationSpinner = new ActionBarNavigationSpinner(this,
new String[] {"Inbox", "Folders", "Accounts"},
new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX,
ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS,
ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS });
mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this);
actionBar.setListNavigationCallbacks(mNavigationSpinner, this);
}

View File

@ -82,4 +82,14 @@ public class ActionBarNavigationSpinner extends ArrayAdapter<String> implements
public long getItemId(int position) {
return mIds[position];
}
public static ActionBarNavigationSpinner getDefaultSpinner(Context context) {
return new ActionBarNavigationSpinner(context,
new String[] {context.getString(R.string.special_mailbox_name_inbox),
context.getString(R.string.folder_list_display_mode_label),
context.getString(R.string.special_mailbox_name_inbox)},
new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX,
ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS,
ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS });
}
}