protected void reloadData() { removePendingDirectorySearchRequests(); mAdapter.onDataReload(); mLoadPriorityDirectoriesOnly = true; mForceLoad = true; startLoading(); }
protected void onPartitionLoaded(int partitionIndex, Cursor data) { if (partitionIndex >= mAdapter.getPartitionCount()) { // When we get unsolicited data, ignore it. This could happen // when we are switching from search mode to the default mode. return; } mAdapter.changeCursor(partitionIndex, data); setProfileHeader(); if (!isLoading()) { completeRestoreInstanceState(); } }
public void setPhotoLoaderEnabled(boolean flag) { mPhotoLoaderEnabled = flag; configurePhotoLoader(); }
@Override public void onHiddenChanged(boolean hidden) { super.onHiddenChanged(hidden); if (getActivity() != null && getView() != null && !hidden) { // If the padding was last applied when in a hidden state, it may have been applied // incorrectly. Therefore we need to reapply it. ContactListViewUtils.applyCardPaddingToView(getResources(), mListView, getView()); } }
protected void onCreateView(LayoutInflater inflater, ViewGroup container) { mView = inflateView(inflater, container); mListView = (ListView)mView.findViewById(android.R.id.list); if (mListView == null) { throw new RuntimeException( "Your content must have a ListView whose id attribute is " + "'android.R.id.list'"); } View emptyView = mView.findViewById(android.R.id.empty); if (emptyView != null) { mListView.setEmptyView(emptyView); } mListView.setOnItemClickListener(this); mListView.setOnItemLongClickListener(this); mListView.setOnFocusChangeListener(this); mListView.setOnTouchListener(this); mListView.setFastScrollEnabled(!isSearchMode()); // Tell list view to not show dividers. We'll do it ourself so that we can *not* show // them when an A-Z headers is visible. mListView.setDividerHeight(0); // We manually save/restore the listview state mListView.setSaveEnabled(false); configureVerticalScrollbar(); configurePhotoLoader(); getAdapter().setFragmentRootView(getView()); ContactListViewUtils.applyCardPaddingToView(getResources(), mListView, mView); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (!mEnabled) { return; } int loaderId = loader.getId(); if (loaderId == DIRECTORY_LOADER_ID) { mDirectoryListStatus = STATUS_LOADED; mAdapter.changeDirectories(data); startLoading(); } else { onPartitionLoaded(loaderId, data); if (isSearchMode()) { int directorySearchMode = getDirectorySearchMode(); if (directorySearchMode != DirectoryListLoader.SEARCH_MODE_NONE) { if (mDirectoryListStatus == STATUS_NOT_LOADED) { mDirectoryListStatus = STATUS_LOADING; getLoaderManager().initLoader(DIRECTORY_LOADER_ID, null, this); } else { startLoading(); } } } else { mDirectoryListStatus = STATUS_NOT_LOADED; getLoaderManager().destroyLoader(DIRECTORY_LOADER_ID); } } }
@Override public void onStart() { super.onStart(); mContactsPrefs.registerChangeListener(mPreferencesChangeListener); mForceLoad = loadPreferences(); mDirectoryListStatus = STATUS_NOT_LOADED; mLoadPriorityDirectoriesOnly = true; startLoading(); }
protected void startLoading() { if (mAdapter == null) { // The method was called before the fragment was started return; } configureAdapter(); int partitionCount = mAdapter.getPartitionCount(); for (int i = 0; i < partitionCount; i++) { Partition partition = mAdapter.getPartition(i); if (partition instanceof DirectoryPartition) { DirectoryPartition directoryPartition = (DirectoryPartition)partition; if (directoryPartition.getStatus() == DirectoryPartition.STATUS_NOT_LOADED) { if (directoryPartition.isPriorityDirectory() || !mLoadPriorityDirectoriesOnly) { startLoadingDirectoryPartition(i); } } } else { getLoaderManager().initLoader(i, null, this); } } // Next time this method is called, we should start loading non-priority directories mLoadPriorityDirectoriesOnly = false; }
@Override protected void startLoading() { mLoaderStarted = true; super.startLoading(); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { super.onLoadFinished(loader, data); if (data == null || data.getCount() == 0) { mEmptyListView.setVisibility(View.VISIBLE); } }
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); restoreSavedState(savedState); mAdapter = createListAdapter(); mContactsPrefs = new ContactsPreferences(mContext); }
public void setVisibleScrollbarEnabled(boolean flag) { if (mVisibleScrollbarEnabled != flag) { mVisibleScrollbarEnabled = flag; configureVerticalScrollbar(); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == DIRECTORY_LOADER_ID) { DirectoryListLoader loader = new DirectoryListLoader(mContext); loader.setDirectorySearchMode(mAdapter.getDirectorySearchMode()); loader.setLocalInvisibleDirectoryEnabled( ContactEntryListAdapter.LOCAL_INVISIBLE_DIRECTORY_ENABLED); return loader; } else { CursorLoader loader = createCursorLoader(mContext); long directoryId = args != null && args.containsKey(DIRECTORY_ID_ARG_KEY) ? args.getLong(DIRECTORY_ID_ARG_KEY) : Directory.DEFAULT; mAdapter.configureLoader(loader, directoryId); return loader; } }
@Override protected void configureAdapter() { super.configureAdapter(); final ContactEntryListAdapter adapter = getAdapter(); if (adapter == null) { return; } if (!isSearchMode() && mFilter != null) { adapter.setFilter(mFilter); } setPhotoPosition(adapter); }
@Override protected void startLoading() { if (PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) { super.startLoading(); mEmptyListView.setDescription(R.string.all_contacts_empty); mEmptyListView.setActionLabel(R.string.all_contacts_empty_add_contact_action); } else { mEmptyListView.setDescription(R.string.permission_no_contacts); mEmptyListView.setActionLabel(R.string.permission_single_turn_on); mEmptyListView.setVisibility(View.VISIBLE); } }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { super.onLoadFinished(loader, data); // disable scroll bar if there is no data setVisibleScrollbarEnabled(data != null && !data.isClosed() && data.getCount() > 0); }
public void setVerticalScrollbarPosition(int position) { if (mVerticalScrollbarPosition != position) { mVerticalScrollbarPosition = position; configureVerticalScrollbar(); } }
public void setSectionHeaderDisplayEnabled(boolean flag) { if (mSectionHeaderDisplayEnabled != flag) { mSectionHeaderDisplayEnabled = flag; if (mAdapter != null) { mAdapter.setSectionHeaderDisplayEnabled(flag); } configureVerticalScrollbar(); } }
/** * Sets a context for the fragment in the unit test environment. */ public void setContext(Context context) { mContext = context; configurePhotoLoader(); }