Search in sources :

Example 1 with Partition

use of com.android.common.widget.CompositeCursorAdapter.Partition in project android_packages_apps_Dialer by LineageOS.

the class ContactEntryListFragment method 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;
}
Also used : Partition(com.android.common.widget.CompositeCursorAdapter.Partition)

Example 2 with Partition

use of com.android.common.widget.CompositeCursorAdapter.Partition in project packages_apps_Contacts by AOKP.

the class ContactBrowseListFragment method checkSelection.

private void checkSelection() {
    if (mSelectionVerified) {
        return;
    }
    if (mRefreshingContactUri) {
        return;
    }
    if (isLoadingDirectoryList()) {
        return;
    }
    ContactListAdapter adapter = getAdapter();
    if (adapter == null) {
        return;
    }
    boolean directoryLoading = true;
    int count = adapter.getPartitionCount();
    for (int i = 0; i < count; i++) {
        Partition partition = adapter.getPartition(i);
        if (partition instanceof DirectoryPartition) {
            DirectoryPartition directory = (DirectoryPartition) partition;
            if (directory.getDirectoryId() == mSelectedContactDirectoryId) {
                directoryLoading = directory.isLoading();
                break;
            }
        }
    }
    if (directoryLoading) {
        return;
    }
    adapter.setSelectedContact(mSelectedContactDirectoryId, mSelectedContactLookupKey, mSelectedContactId);
    final int selectedPosition = adapter.getSelectedContactPosition();
    if (selectedPosition != -1) {
        mLastSelectedPosition = selectedPosition;
    } else {
        if (isSearchMode()) {
            if (mDelaySelection) {
                selectFirstFoundContactAfterDelay();
                if (mListener != null) {
                    mListener.onSelectionChange();
                }
                return;
            }
        } else if (mSelectionRequired) {
            // A specific contact was requested, but it's not in the loaded list.
            // Try reconfiguring and reloading the list that will hopefully contain
            // the requested contact. Only take one attempt to avoid an infinite loop
            // in case the contact cannot be found at all.
            mSelectionRequired = false;
            // FILTER_TYPE cases.
            if (mFilter != null && (mFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT || mFilter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS)) {
                reloadData();
            } else {
                // Otherwise, call the listener, which will adjust the filter.
                notifyInvalidSelection();
            }
            return;
        } else if (mFilter != null && mFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
            // If we were trying to load a specific contact, but that contact no longer
            // exists, call the listener, which will adjust the filter.
            notifyInvalidSelection();
            return;
        }
        saveSelectedUri(null);
        selectDefaultContact();
    }
    mSelectionRequired = false;
    mSelectionVerified = true;
    if (mSelectionPersistenceRequested) {
        saveSelectedUri(mSelectedContactUri);
        mSelectionPersistenceRequested = false;
    }
    if (mSelectionToScreenRequested) {
        requestSelectionToScreen(selectedPosition);
    }
    getListView().invalidateViews();
    if (mListener != null) {
        mListener.onSelectionChange();
    }
}
Also used : Partition(com.android.common.widget.CompositeCursorAdapter.Partition) DirectoryPartition(com.android.contacts.common.list.DirectoryPartition) ContactListAdapter(com.android.contacts.common.list.ContactListAdapter) DirectoryPartition(com.android.contacts.common.list.DirectoryPartition)

Aggregations

Partition (com.android.common.widget.CompositeCursorAdapter.Partition)2 ContactListAdapter (com.android.contacts.common.list.ContactListAdapter)1 DirectoryPartition (com.android.contacts.common.list.DirectoryPartition)1