diff options
author | Andrew Sapperstein <asapperstein@google.com> | 2014-07-30 18:12:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-29 21:36:00 +0000 |
commit | 121084b946d54fa429b9e139b826d0e20cdb7015 (patch) | |
tree | 49488d3e04e913fd283a6429bdeb84331f9cbe45 /src | |
parent | f318bc3cb806774a07421a413a918aa6afb8792f (diff) | |
parent | a82089dd7b9a48eac5eeb30934ee3a3123646ebd (diff) | |
download | android_packages_apps_UnifiedEmail-121084b946d54fa429b9e139b826d0e20cdb7015.tar.gz android_packages_apps_UnifiedEmail-121084b946d54fa429b9e139b826d0e20cdb7015.tar.bz2 android_packages_apps_UnifiedEmail-121084b946d54fa429b9e139b826d0e20cdb7015.zip |
Merge "Support header views in the folder list." into ub-mail-master
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/mail/ui/FolderListFragment.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/com/android/mail/ui/FolderListFragment.java b/src/com/android/mail/ui/FolderListFragment.java index 5bcdb0b72..64537f9b9 100644 --- a/src/com/android/mail/ui/FolderListFragment.java +++ b/src/com/android/mail/ui/FolderListFragment.java @@ -414,10 +414,11 @@ public class FolderListFragment extends ListFragment implements Bundle savedState) { setInstanceFromBundle(getArguments()); - final View rootView = inflateRootView(inflater, container); + final View rootView = inflater.inflate(R.layout.folder_list, container, false); mListView = (ListView) rootView.findViewById(android.R.id.list); mListView.setEmptyView(null); mListView.setDivider(null); + addListHeader(inflater, mListView); if (savedState != null && savedState.containsKey(BUNDLE_LIST_STATE)) { mListView.onRestoreInstanceState(savedState.getParcelable(BUNDLE_LIST_STATE)); } @@ -439,8 +440,8 @@ public class FolderListFragment extends ListFragment implements return rootView; } - protected View inflateRootView(LayoutInflater inflater, ViewGroup parent) { - return inflater.inflate(R.layout.folder_list, parent, false); + protected void addListHeader(LayoutInflater inflater, ListView list) { + // Default impl does nothing } @Override @@ -538,7 +539,8 @@ public class FolderListFragment extends ListFragment implements * @param position a zero indexed position into the list. */ protected void viewFolderOrChangeAccount(int position) { - final Object item = getListAdapter().getItem(position); + // Get the ListView's adapter + final Object item = getListView().getAdapter().getItem(position); LogUtils.d(LOG_TAG, "viewFolderOrChangeAccount(%d): %s", position, item); final Folder folder; int folderType = DrawerItem.UNSET; @@ -742,10 +744,12 @@ public class FolderListFragment extends ListFragment implements final DrawerItem item = (DrawerItem) getItem(position); final View view = item.getView(convertView, parent); final int type = item.mType; - final boolean isSelected = item.isHighlighted(mSelectedFolderUri, mSelectedDrawerItemType); + final boolean isSelected = + item.isHighlighted(mSelectedFolderUri, mSelectedDrawerItemType); if (type == DrawerItem.VIEW_FOLDER) { mListView.setItemChecked((mAccountsAdapter != null ? - mAccountsAdapter.getCount() : 0) + position, isSelected); + mAccountsAdapter.getCount() : 0) + + position + mListView.getHeaderViewsCount(), isSelected); } // If this is the current folder, also check to verify that the unread count // matches what the action bar shows. @@ -1053,8 +1057,10 @@ public class FolderListFragment extends ListFragment implements } folderItemView.bind(folder, mDropHandler); if (folder.folderUri.equals(mSelectedFolderUri)) { - getListView().setItemChecked((mAccountsAdapter != null ? - mAccountsAdapter.getCount() : 0) + position, true); + final ListView listView = getListView(); + listView.setItemChecked((mAccountsAdapter != null ? + mAccountsAdapter.getCount() : 0) + + position + listView.getHeaderViewsCount(), true); // If this is the current folder, also check to verify that the unread count // matches what the action bar shows. final boolean unreadCountDiffers = (mCurrentFolderForUnreadCheck != null) @@ -1166,6 +1172,10 @@ public class FolderListFragment extends ListFragment implements return mCurrentAccount == null ? "" : mCurrentAccount.getEmailAddress(); } + protected MergedAdapter<ListAdapter> getMergedAdapter() { + return mMergedAdapter; + } + private class FooterAdapter extends BaseAdapter { private final List<FooterItem> mFooterItems = Lists.newArrayList(); @@ -1487,4 +1497,11 @@ public class FolderListFragment extends ListFragment implements } } } + + @Override + public ListAdapter getListAdapter() { + // Ensures that we get the adapter with the header views. + throw new UnsupportedOperationException("Use getListView().getAdapter() instead " + + "which accounts for any header or footer views."); + } } |