Add loaders to DrawerFragment and make status bar transparent
- This CL addresses a TODO to load groups and filters from
DrawerFragment directly.
- Also, avoiding adding fragments to FragmentManager of a
Fragment works around a crash on LMP.
- Wrap RecyclerView with a FrameLayout to go full screen
with a ScrimDrawable
Bug: 34062530
Test: add and remove accounts and observe changes in side nav
Change-Id: I63943a9d596aa32301609d6ab1b9d49c0c784356
diff --git a/res/layout/drawer_fragment.xml b/res/layout/drawer_fragment.xml
index ea9eed0..eeb792e 100644
--- a/res/layout/drawer_fragment.xml
+++ b/res/layout/drawer_fragment.xml
@@ -15,15 +15,18 @@
limitations under the License.
-->
+<!-- Layout for the navigation drawer. The content view needs to be wrapped in a FrameLayout in
+ order to go full screen with a ScrimDrawable. -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_fragment_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
- android:background="#FAFAFA"
+ android:background="@color/navigation_drawer_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null" />
diff --git a/res/layout/nav_drawer_spacer b/res/layout/nav_drawer_spacer.xml
similarity index 100%
rename from res/layout/nav_drawer_spacer
rename to res/layout/nav_drawer_spacer.xml
diff --git a/res/layout/nav_header_main.xml b/res/layout/nav_header_main.xml
index 518e6e6..7a2e3cb 100644
--- a/res/layout/nav_header_main.xml
+++ b/res/layout/nav_header_main.xml
@@ -16,16 +16,10 @@
limitations under the License.
-->
-<LinearLayout
+<View
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/nav_status_bar_spacer"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@color/contacts_accent_color"
- android:gravity="bottom"
- android:orientation="vertical"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- android:theme="@style/ThemeOverlay.AppCompat.Dark">
-</LinearLayout>
+ android:importantForAccessibility="no"/>
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 4a222ad..48ebeee 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -1124,7 +1124,7 @@
}
private void selectAccountForNewGroup() {
- // This should never block because the GroupsFragment loads the accounts and the
+ // This should never block because the DrawerFragment loads the accounts and the
// "Create Label" item only exists when that loading finishes
final List<AccountInfo> accounts = Futures.getUnchecked(AccountTypeManager.getInstance(this)
.filterAccountsAsync(AccountTypeManager.AccountFilter.GROUPS_WRITABLE));
diff --git a/src/com/android/contacts/drawer/DrawerAdapter.java b/src/com/android/contacts/drawer/DrawerAdapter.java
index 959d478..c6d3c4d 100644
--- a/src/com/android/contacts/drawer/DrawerAdapter.java
+++ b/src/com/android/contacts/drawer/DrawerAdapter.java
@@ -47,7 +47,8 @@
private static final int VIEW_TYPE_ACCOUNT_ENTRY = 4;
private static final int VIEW_TYPE_CREATE_LABEL = 5;
private static final int VIEW_TYPE_NAV_SPACER = 6;
- private static final int VIEW_TYPE_NAV_DIVIDER = 7;
+ private static final int VIEW_TYPE_STATUS_SPACER = 7;
+ private static final int VIEW_TYPE_NAV_DIVIDER = 8;
private static final int TYPEFACE_STYLE_ACTIVATE = R.style.DrawerItemTextActiveStyle;
private static final int TYPEFACE_STYLE_INACTIVE = R.style.DrawerItemTextInactiveStyle;
@@ -61,7 +62,8 @@
private long mSelectedGroupId;
private ContactListFilter mSelectedAccount;
- // Adapter elements, ordered in this way in the getItem() method. The ordering is based on:
+ // Adapter elements, ordered in this way mItemsList. The ordering is based on:
+ // [Status bar spacer item]
// [Navigation spacer item]
// [Primary items] (Contacts, Suggestions)
// [Group Header]
@@ -71,6 +73,7 @@
// [Accounts]
// [Misc items] (a divider, Settings, Help & Feedback)
// [Navigation spacer item]
+ private StatusBarSpacerItem mStatusBarSpacerItem = null;
private NavSpacerItem mNavSpacerItem = null;
private List<PrimaryItem> mPrimaryItems = new ArrayList<>();
private HeaderItem mGroupHeader = null;
@@ -94,6 +97,7 @@
private void initializeDrawerMenuItems() {
// Spacer item for dividing sections in drawer
mNavSpacerItem = new NavSpacerItem(R.id.nav_drawer_spacer);
+ mStatusBarSpacerItem = new StatusBarSpacerItem(R.id.nav_status_bar_spacer);
// Primary items
mPrimaryItems.add(new PrimaryItem(R.id.nav_all_contacts, R.string.contactsList,
R.drawable.quantum_ic_account_circle_vd_theme_24, ContactsView.ALL_CONTACTS));
@@ -117,6 +121,7 @@
private void rebuildItemsList() {
mItemsList.clear();
+ mItemsList.add(mStatusBarSpacerItem);
mItemsList.add(mNavSpacerItem);
mItemsList.addAll(mPrimaryItems);
if (mAreGroupWritableAccountsAvailable) {
@@ -184,6 +189,8 @@
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
+ case VIEW_TYPE_STATUS_SPACER:
+ return getBaseViewHolder(R.layout.nav_header_main, parent);
case VIEW_TYPE_NAV_SPACER:
return getBaseViewHolder(R.layout.nav_drawer_spacer, parent);
case VIEW_TYPE_PRIMARY_ITEM:
@@ -394,6 +401,15 @@
}
}
+
+ // Navigation drawer item for status bar spacer item to take up the height of status bar in the
+ // drawer.
+ public static class StatusBarSpacerItem extends BaseDrawerItem {
+ public StatusBarSpacerItem(int id) {
+ super(VIEW_TYPE_STATUS_SPACER, id, /* textResId */ 0, /* iconResId */ 0);
+ }
+ }
+
// Navigation drawer item for spacer item for dividing sections in the drawer.
public static class NavSpacerItem extends BaseDrawerItem {
public NavSpacerItem(int id) {
diff --git a/src/com/android/contacts/drawer/DrawerFragment.java b/src/com/android/contacts/drawer/DrawerFragment.java
index b57f151..2c8bfba 100644
--- a/src/com/android/contacts/drawer/DrawerFragment.java
+++ b/src/com/android/contacts/drawer/DrawerFragment.java
@@ -18,48 +18,62 @@
import android.app.Activity;
import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
+import android.app.LoaderManager;
+import android.content.CursorLoader;
+import android.content.Loader;
import android.database.ContentObserver;
+import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets;
+import android.widget.FrameLayout;
+import com.android.contacts.GroupListLoader;
import com.android.contacts.R;
import com.android.contacts.activities.PeopleActivity.ContactsView;
import com.android.contacts.group.GroupListItem;
import com.android.contacts.group.GroupUtil;
-import com.android.contacts.group.GroupsFragment;
-import com.android.contacts.group.GroupsFragment.GroupsListener;
-import com.android.contacts.interactions.AccountFiltersFragment;
-import com.android.contacts.interactions.AccountFiltersFragment.AccountFiltersListener;
import com.android.contacts.list.ContactListFilter;
+import com.android.contacts.model.AccountTypeManager;
+import com.android.contacts.model.account.AccountInfo;
+import com.android.contacts.model.account.AccountsLoader;
+import com.android.contacts.model.account.AccountsLoader.AccountsListener;
+import com.android.contacts.util.AccountFilterUtil;
import com.android.contactsbind.ObjectFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-public class DrawerFragment extends Fragment implements AccountFiltersListener, GroupsListener {
+public class DrawerFragment extends Fragment implements AccountsListener{
+
+ private static final int LOADER_GROUPS = 1;
+ private static final int LOADER_ACCOUNTS = 2;
+ private static final int LOADER_FILTERS = 3;
+
+ private static final String KEY_CONTACTS_VIEW = "contactsView";
+ private static final String KEY_SELECTED_GROUP = "selectedGroup";
+ private static final String KEY_SELECTED_ACCOUNT = "selectedAccount";
private WelcomeContentObserver mObserver;
private RecyclerView mDrawerRecyclerView;
private DrawerAdapter mDrawerAdapter;
private ContactsView mCurrentContactsView;
private DrawerFragmentListener mListener;
- private GroupsFragment mGroupsFragment;
- private AccountFiltersFragment mAccountFiltersFragment;
+ // Transparent scrim drawn at the top of the drawer fragment.
+ private ScrimDrawable mScrimDrawable;
- private static final String TAG_GROUPS = "groups";
- private static final String TAG_FILTERS = "filters";
- private static final String KEY_CONTACTS_VIEW = "contactsView";
- private static final String KEY_SELECTED_GROUP = "selectedGroup";
- private static final String KEY_SELECTED_ACCOUNT = "selectedAccount";
+ private List<GroupListItem> mGroupListItems = new ArrayList<>();
+ private boolean mGroupsLoaded;
+ private boolean mAccountsLoaded;
+ private boolean mHasGroupWritableAccounts;
private final class WelcomeContentObserver extends ContentObserver {
private WelcomeContentObserver(Handler handler) {
@@ -72,6 +86,55 @@
}
}
+ private final LoaderManager.LoaderCallbacks<List<ContactListFilter>> mFiltersLoaderListener =
+ new LoaderManager.LoaderCallbacks<List<ContactListFilter>> () {
+ @Override
+ public Loader<List<ContactListFilter>> onCreateLoader(int id, Bundle args) {
+ return new AccountFilterUtil.FilterLoader(getActivity());
+ }
+
+ @Override
+ public void onLoadFinished(
+ Loader<List<ContactListFilter>> loader, List<ContactListFilter> data) {
+ if (data != null) {
+ if (data == null || data.size() < 2) {
+ mDrawerAdapter.setAccounts(new ArrayList<ContactListFilter>());
+ } else {
+ mDrawerAdapter.setAccounts(data);
+ }
+ }
+ }
+
+ public void onLoaderReset(Loader<List<ContactListFilter>> loader) {
+ }
+ };
+
+ private final LoaderManager.LoaderCallbacks<Cursor> mGroupListLoaderListener =
+ new LoaderManager.LoaderCallbacks<Cursor>() {
+ @Override
+ public CursorLoader onCreateLoader(int id, Bundle args) {
+ return new GroupListLoader(getActivity());
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ if (data == null) {
+ return;
+ }
+ mGroupListItems.clear();
+ for (int i = 0; i < data.getCount(); i++) {
+ if (data.moveToNext()) {
+ mGroupListItems.add(GroupUtil.getGroupListItem(data, i));
+ }
+ }
+ mGroupsLoaded = true;
+ notifyIfReady();
+ }
+
+ public void onLoaderReset(Loader<Cursor> loader) {
+ }
+ };
+
public DrawerFragment() {}
@Override
@@ -109,6 +172,14 @@
setNavigationItemChecked(ContactsView.ALL_CONTACTS);
}
+ final FrameLayout root = (FrameLayout) contentView.findViewById(R.id.drawer_fragment_root);
+ root.setFitsSystemWindows(true);
+ root.setOnApplyWindowInsetsListener(new WindowInsetsListener());
+ root.setForegroundGravity(Gravity.TOP | Gravity.FILL_HORIZONTAL);
+
+ mScrimDrawable = new ScrimDrawable();
+ root.setForeground(mScrimDrawable);
+
return contentView;
}
@@ -139,27 +210,11 @@
}
}
- // TODO create loaders in this fragment instead of having separate fragments that just kick off
- // some data loading.
private void loadGroupsAndFilters() {
- final FragmentManager fragmentManager = getFragmentManager();
- final FragmentTransaction transaction = fragmentManager.beginTransaction();
- mGroupsFragment = (GroupsFragment) fragmentManager.findFragmentByTag(TAG_GROUPS);
- if (mGroupsFragment == null) {
- mGroupsFragment = new GroupsFragment();
- transaction.add(mGroupsFragment, TAG_GROUPS);
- }
- mGroupsFragment.setListener(this);
-
- mAccountFiltersFragment = (AccountFiltersFragment)
- fragmentManager.findFragmentByTag(TAG_FILTERS);
- if (mAccountFiltersFragment == null) {
- mAccountFiltersFragment = new AccountFiltersFragment();
- transaction.add(mAccountFiltersFragment, TAG_FILTERS);
- }
- mAccountFiltersFragment.setListener(this);
- transaction.commitAllowingStateLoss();
- fragmentManager.executePendingTransactions();
+ getLoaderManager().initLoader(LOADER_FILTERS, null, mFiltersLoaderListener);
+ AccountsLoader.loadAccounts(this, LOADER_ACCOUNTS,
+ AccountTypeManager.AccountFilter.GROUPS_WRITABLE);
+ getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupListLoaderListener);
}
@Override
@@ -211,29 +266,28 @@
}
}
- @Override
- public void onGroupsLoaded(List<GroupListItem> groupListItems, boolean areGroupWritable) {
- final Iterator<GroupListItem> iterator = groupListItems.iterator();
- while (iterator.hasNext()) {
- final GroupListItem groupListItem = iterator.next();
- if (GroupUtil.isEmptyFFCGroup(groupListItem)) {
- iterator.remove();
- }
- }
- mDrawerAdapter.setGroups(groupListItems, areGroupWritable);
- }
-
public void updateGroupMenu(long groupId) {
mDrawerAdapter.setSelectedGroupId(groupId);
setNavigationItemChecked(ContactsView.GROUP_VIEW);
}
@Override
- public void onFiltersLoaded(List<ContactListFilter> accountFilterItems) {
- if (accountFilterItems == null || accountFilterItems.size() < 2) {
- mDrawerAdapter.setAccounts(new ArrayList<ContactListFilter>());
- } else {
- mDrawerAdapter.setAccounts(accountFilterItems);
+ public void onAccountsLoaded(List<AccountInfo> accounts) {
+ mHasGroupWritableAccounts = !accounts.isEmpty();
+ mAccountsLoaded = true;
+ notifyIfReady();
+ }
+
+ private void notifyIfReady() {
+ if (mAccountsLoaded && mGroupsLoaded) {
+ final Iterator<GroupListItem> iterator = mGroupListItems.iterator();
+ while (iterator.hasNext()) {
+ final GroupListItem groupListItem = iterator.next();
+ if (GroupUtil.isEmptyFFCGroup(groupListItem)) {
+ iterator.remove();
+ }
+ }
+ mDrawerAdapter.setGroups(mGroupListItems, mHasGroupWritableAccounts);
}
}
@@ -246,4 +300,14 @@
void onOpenSettings();
void onLaunchHelpFeedback();
}
+
+ private class WindowInsetsListener implements View.OnApplyWindowInsetsListener {
+ @Override
+ public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
+ final int insetTop = insets.getSystemWindowInsetTop();
+ // set height of the scrim
+ mScrimDrawable.setIntrinsicHeight(insetTop);
+ return insets;
+ }
+ }
}
diff --git a/src/com/android/contacts/drawer/ScrimDrawable.java b/src/com/android/contacts/drawer/ScrimDrawable.java
new file mode 100644
index 0000000..5663b1b
--- /dev/null
+++ b/src/com/android/contacts/drawer/ScrimDrawable.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.contacts.drawer;
+
+import android.graphics.drawable.ColorDrawable;
+
+/**
+ * Create a simple scrim that covers just the status bar area when necessary.
+ * Copied from com.google.android.gms.people.accountswitcherview.ScrimDrawable;
+ */
+public class ScrimDrawable extends ColorDrawable {
+ public static final int DEFAULT_COLOR = 0x33000000;
+
+ /**
+ * Default constructor. Uses default color.
+ */
+ public ScrimDrawable() {
+ this(DEFAULT_COLOR);
+ }
+
+ /**
+ * Set a color if necessary.
+ *
+ * @param color
+ */
+ public ScrimDrawable(int color) {
+ super(color);
+ }
+
+ private int mIntrinsicHeight;
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mIntrinsicHeight;
+ }
+
+ public void setIntrinsicHeight(int intrinsicHeight) {
+ mIntrinsicHeight = intrinsicHeight;
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/contacts/group/GroupUtil.java b/src/com/android/contacts/group/GroupUtil.java
index a4a02a6..706f16b 100644
--- a/src/com/android/contacts/group/GroupUtil.java
+++ b/src/com/android/contacts/group/GroupUtil.java
@@ -70,7 +70,7 @@
}
/** Returns a {@link GroupListItem} read from the given cursor and position. */
- static GroupListItem getGroupListItem(Cursor cursor, int position) {
+ public static GroupListItem getGroupListItem(Cursor cursor, int position) {
if (cursor == null || cursor.isClosed() || !cursor.moveToPosition(position)) {
return null;
}
diff --git a/src/com/android/contacts/group/GroupsFragment.java b/src/com/android/contacts/group/GroupsFragment.java
deleted file mode 100644
index e2a1de4..0000000
--- a/src/com/android/contacts/group/GroupsFragment.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.contacts.group;
-
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.content.CursorLoader;
-import android.content.Loader;
-import android.database.Cursor;
-import android.os.Bundle;
-
-import com.android.contacts.GroupListLoader;
-import com.android.contacts.model.AccountTypeManager;
-import com.android.contacts.model.account.AccountInfo;
-import com.android.contacts.model.account.AccountsLoader;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Loads groups and group metadata for all accounts.
- */
-public final class GroupsFragment extends Fragment implements AccountsLoader.AccountsListener {
-
- private static final int LOADER_GROUPS = 1;
- private static final int LOADER_ACCOUNTS = 2;
-
- /**
- * Callbacks for hosts of the {@link GroupsFragment}.
- */
- public interface GroupsListener {
-
- /**
- * Invoked after groups and group metadata have been loaded.
- */
- void onGroupsLoaded(List<GroupListItem> groupListItems,
- boolean areGroupWritableAccountsAvailable);
- }
-
- private final LoaderManager.LoaderCallbacks<Cursor> mGroupListLoaderListener =
- new LoaderManager.LoaderCallbacks<Cursor>() {
-
- @Override
- public CursorLoader onCreateLoader(int id, Bundle args) {
- return new GroupListLoader(getActivity());
- }
-
- @Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- if (data == null) {
- return;
- }
- mGroupListItems.clear();
- for (int i = 0; i < data.getCount(); i++) {
- if (data.moveToNext()) {
- mGroupListItems.add(GroupUtil.getGroupListItem(data, i));
- }
- }
- mGroupsLoaded = true;
- notifyIfReady();
- }
-
- public void onLoaderReset(Loader<Cursor> loader) {
- }
- };
-
- private List<GroupListItem> mGroupListItems = new ArrayList<>();
- private boolean mHasGroupWritableAccounts = false;
- private boolean mGroupsLoaded = false;
- private boolean mAccountsLoaded = false;
- private GroupsListener mListener;
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- AccountsLoader.loadAccounts(this, LOADER_ACCOUNTS,
- AccountTypeManager.AccountFilter.GROUPS_WRITABLE);
- getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupListLoaderListener);
- }
-
- public void setListener(GroupsListener listener) {
- mListener = listener;
- }
-
- @Override
- public void onAccountsLoaded(List<AccountInfo> accounts) {
- mHasGroupWritableAccounts = !accounts.isEmpty();
- mAccountsLoaded = true;
- notifyIfReady();
- }
-
- private void notifyIfReady() {
- if (mAccountsLoaded && mGroupsLoaded && mListener != null) {
- mListener.onGroupsLoaded(mGroupListItems, mHasGroupWritableAccounts);
- }
- }
-}
diff --git a/src/com/android/contacts/interactions/AccountFiltersFragment.java b/src/com/android/contacts/interactions/AccountFiltersFragment.java
deleted file mode 100644
index e1d882e..0000000
--- a/src/com/android/contacts/interactions/AccountFiltersFragment.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.contacts.interactions;
-
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.content.Loader;
-import android.os.Bundle;
-
-import com.android.contacts.list.ContactListFilter;
-import com.android.contacts.util.AccountFilterUtil;
-
-import java.util.List;
-
-/**
- * Loads account filters.
- */
-public class AccountFiltersFragment extends Fragment {
-
- private static final int LOADER_FILTERS = 1;
-
- /**
- * Callbacks for hosts of the {@link AccountFiltersFragment}.
- */
- public interface AccountFiltersListener {
-
- /**
- * Invoked after account filters have been loaded.
- */
- void onFiltersLoaded(List<ContactListFilter> accountFilterItems);
- }
-
- private final LoaderManager.LoaderCallbacks<List<ContactListFilter>> mFiltersLoaderListener =
- new LoaderManager.LoaderCallbacks<List<ContactListFilter>> () {
- @Override
- public Loader<List<ContactListFilter>> onCreateLoader(int id, Bundle args) {
- return new AccountFilterUtil.FilterLoader(getActivity());
- }
-
- @Override
- public void onLoadFinished(
- Loader<List<ContactListFilter>> loader, List<ContactListFilter> data) {
- if (mListener != null && data != null) {
- mListener.onFiltersLoaded(data);
- }
- }
-
- public void onLoaderReset(Loader<List<ContactListFilter>> loader) {
- }
- };
-
- private AccountFiltersListener mListener;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void onStart() {
- getLoaderManager().initLoader(LOADER_FILTERS, null, mFiltersLoaderListener);
-
- super.onStart();
- }
-
- public void setListener(AccountFiltersListener listener) {
- mListener = listener;
- }
-}