summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Sapperstein <asapperstein@google.com>2014-07-29 13:28:18 -0700
committerAndrew Sapperstein <asapperstein@google.com>2014-07-29 19:13:30 -0700
commita82089dd7b9a48eac5eeb30934ee3a3123646ebd (patch)
tree3161cb663cef4c4f818fcb1f2182775b62d0dd51 /src
parent0adf3fa87b007e9fa7e3e718bb5111fd47178110 (diff)
downloadandroid_packages_apps_UnifiedEmail-a82089dd7b9a48eac5eeb30934ee3a3123646ebd.tar.gz
android_packages_apps_UnifiedEmail-a82089dd7b9a48eac5eeb30934ee3a3123646ebd.tar.bz2
android_packages_apps_UnifiedEmail-a82089dd7b9a48eac5eeb30934ee3a3123646ebd.zip
Support header views in the folder list.
Change-Id: Ib5e85a4a74f021392cebefc3b3f2945e7f4b0643
Diffstat (limited to 'src')
-rw-r--r--src/com/android/mail/ui/FolderListFragment.java33
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.");
+ }
}