/** {@inheritDoc} from Fragment */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAllContactsListViewHolder = new AllContactsListViewHolder(getActivity(), this); mFrequentContactsListViewHolder = new FrequentContactsListViewHolder(getActivity(), this); if (ContactUtil.hasReadContactsPermission()) { mBinding.bind(DataModel.get().createContactPickerData(getActivity(), this)); mBinding.getData().init(getLoaderManager(), mBinding); } }
@Override public void onDestroy() { super.onDestroy(); // We could not have bound to the data if the permission was denied. if (mBinding.isBound()) { mBinding.unbind(); } if (mMonitor != null) { mMonitor.unregister(); } mMonitor = null; }
@Override // From ContactPickerDataListener public void onFrequentContactsCursorUpdated(final Cursor data) { mBinding.ensureBound(); mFrequentContactsListViewHolder.onContactsCursorUpdated(data); if (data != null && data.getCount() == 0) { // Show the all contacts list when there's no frequents. mCustomHeaderViewPager.setCurrentItem(1); } }
@Override public void onContactCustomColorLoaded(final ContactPickerData data) { mBinding.ensureBound(data); invalidateContactLists(); }
@Override // From ContactPickerDataListener public void onAllContactsCursorUpdated(final Cursor data) { mBinding.ensureBound(); mAllContactsListViewHolder.onContactsCursorUpdated(data); }