Java 类android.widget.FilterQueryProvider 实例源码

项目:KinoCast    文件:SearchSuggestionAdapter.java   
public SearchSuggestionAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
    super(context, layout, c, from, to, flags);

    setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            MatrixCursor matrixCursor = new MatrixCursor(new String[] { "_id", "item" });

            if(constraint == null) return matrixCursor;
            String query = constraint.toString();
            if(TextUtils.isEmpty(query)) return matrixCursor;
            String suggestions[] = Parser.getInstance().getSearchSuggestions(query);
            if(suggestions == null) return matrixCursor;

            for (int i = 0; i < suggestions.length; i++) {
                matrixCursor.addRow(new Object[]{(i + 1), suggestions[i]});
            }

            return matrixCursor;
        }
    });
}
项目:EngMyanDictionary    文件:MainListFragment.java   
public void prepareSearch(CharSequence query) {
    if (mRecyclerView == null) return;

    Cursor cursor = null;
    if (!TextUtils.isEmpty(query)) {
        cursor = SearchQueryHelper.getInstance(getContext()).query(query);
    } else {
        cursor = SearchQueryHelper.getInstance(getContext()).querySuggestWord();
    }

    mListAdapter = new SearchListAdapter(getContext(), cursor, DictionaryDataProvider.COLUMN_WORD, 
            mRecyclerView, Constants.SEARCH_LIST_ITEM_LIMIT);
    mListAdapter.setFilterQueryProvider(new FilterQueryProvider() {

        @Override
        public Cursor runQuery(CharSequence constraint) {
            return SearchQueryHelper.getInstance(getContext()).query(constraint);
        }
    });
    mListAdapter.setOnItemClickListener(this);
    mRecyclerView.setAdapter(mListAdapter);
}
项目:quiz_helper    文件:Collins.java   
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:quiz_helper    文件:WebsterLearners.java   
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{"hwd"},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:quiz_helper    文件:Ode2.java   
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:quiz_helper    文件:CustomDictionary.java   
@Override
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout, null,
                    new String[] {CustomDictionaryDbHelper.getHeadwordColumnName()},
                    new int[] {android.R.id.text1},
                    0
                    );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return mDbHelper.getFilterCursor(mDictId, constraint.toString());
                }
            }
    );

    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:ankihelper    文件:Collins.java   
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:ankihelper    文件:WebsterLearners.java   
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{"hwd"},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:ankihelper    文件:Ode2.java   
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:ankihelper    文件:CustomDictionary.java   
@Override
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout, null,
                    new String[] {CustomDictionaryDbHelper.getHeadwordColumnName()},
                    new int[] {android.R.id.text1},
                    0
                    );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return mDbHelper.getFilterCursor(mDictId, constraint.toString());
                }
            }
    );

    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
项目:xowa_android    文件:EditSummaryHandler.java   
public EditSummaryHandler(final Activity activity, View container,
                          AutoCompleteTextView summaryEditText, PageTitle title) {
    this.activity = activity;
    this.container = container;
    this.summaryEdit = summaryEditText;

    this.container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            summaryEdit.requestFocus();
        }
    });

    EditSummaryAdapter adapter = new EditSummaryAdapter(activity, null, true);
    summaryEdit.setAdapter(adapter);
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        @Override
        public Cursor runQuery(CharSequence charSequence) {
            ContentProviderClient client = activity.getContentResolver()
                                   .acquireContentProviderClient(EditSummary.PERSISTENCE_HELPER
                                                                         .getBaseContentURI());
            try {
                return client.query(
                        EditSummary.PERSISTENCE_HELPER.getBaseContentURI(),
                        null,
                        "summary LIKE ?",
                        new String[] {charSequence + "%"},
                        "lastUsed DESC");
            } catch (RemoteException e) {
                // This shouldn't really be happening
                throw new RuntimeException(e);
            } finally {
                client.release();
            }
        }
    });

    setConditionalTextDirection(summaryEdit, title.getSite().getLanguageCode());
}
项目:LyricHere    文件:LyricCursorAdapter.java   
public LyricCursorAdapter(final Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
    super(context, layout, c, from, to, flags);
    setFilterQueryProvider(new FilterQueryProvider() {
        @Override
        public Cursor runQuery(CharSequence constraint) {
            LogUtils.d(TAG, "runQuery: " + constraint);
            return DbUtils.searchByKeyword(context.getContentResolver(), constraint.toString());
        }
    });
}
项目:ApkLauncher    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:downtown    文件:QueryBuilder.java   
/**
 * Creates a SearchFilterProvider that searches through the columns set in {@link #setSearchColumns(String...)}.
 * @param context
 * @return
 */
public FilterQueryProvider createSearchFilterQueryProvider( final Context context, final Uri uri ) {
    return new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            setSearchQuery( TextUtils.isEmpty( constraint ) ? null : constraint.toString() );
            return query( context, uri );
        }
    };
}
项目:ApiDemos    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:StoryTeller    文件:MainActivity.java   
@Override
public void onLoadFinished(Loader loader, Cursor cursor) {
    Log.v(TAG, "Cursor retrieved");
    mCustomCursorAdapter = new CustomCursorAdapter(MainActivity.this, R.layout.story_layout,
            cursor, MainDatabase.TableStory.COLUMNS_SHOWN, to, 0, this);
    mStoriesGridView.setAdapter(mCustomCursorAdapter);

    mCustomCursorAdapter.setFilterQueryProvider(new FilterQueryProvider() {
        @Override
        public Cursor runQuery(CharSequence constraint) {
            return mStoryDataLayer.searchStoryByText(constraint.toString());
        }
    });
    setSupportProgressBarIndeterminateVisibility(false);
}
项目:felix-on-android    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:MEng    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:codeexamples-android    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:deview-2013-samples    文件:AutoComplete4.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    FilterQueryProvider filter = getFilterQueryProvider();
    if (filter != null) {
        return filter.runQuery(constraint);
    }

    Uri uri = Uri.withAppendedPath(
            Contacts.CONTENT_FILTER_URI,
            Uri.encode(constraint.toString()));
    return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
项目:android_xcore    文件:XListFragment.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
       ListAdapter adapter = getListAdapter();
    FragmentActivity activity = getActivity();
    if (activity == null) {
        return;
    }
    if (adapter == null || !(adapter instanceof CursorAdapter)) {
        BaseAdapter baseAdapter = createAdapter(activity, cursor);
        ViewBinder adapterViewBinder = getAdapterViewBinder();
        if (adapterViewBinder != null && baseAdapter instanceof ISetViewBinder) {
               ((ISetViewBinder)baseAdapter).setViewBinder(adapterViewBinder);
        }
           if (baseAdapter instanceof CursorAdapter) {
               ((CursorAdapter)baseAdapter).setFilterQueryProvider(new FilterQueryProvider() {

                   @Override
                   public Cursor runQuery(CharSequence constraint) {
                       return runSearchQuery(getActivity(), constraint);
                   }

               });
           }
        adapter = baseAdapter;
        setListAdapter(adapter);
    } else {
        ((CursorAdapter) adapter).swapCursor(cursor);
    }
       //plugins
       List<IFragmentPlugin> listFragmentPlugins = XCoreHelper.get(getActivity()).getListFragmentPlugins();
       if (listFragmentPlugins != null) {
           for(IFragmentPlugin plugin : listFragmentPlugins) {
               plugin.onLoadFinished(this, loader, cursor);
           }
       }
       setLoaderWork(false, LOADER_PRIORITY_HIGH);
       checkStatus("onLoadFinished");
}
项目:letv    文件:CursorAdapter.java   
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
项目:letv    文件:CursorAdapter.java   
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
项目:letv    文件:CursorAdapter.java   
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
项目:letv    文件:CursorAdapter.java   
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
项目:boohee_v5.6    文件:CursorAdapter.java   
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
项目:boohee_v5.6    文件:CursorAdapter.java   
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
项目:Ouroboros    文件:CatalogFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
    inflater.inflate(R.menu.menu_catalog, menu);
    MenuItem replyButton = menu.findItem(R.id.action_reply);
    MenuItem openExternalButton = menu.findItem(R.id.action_external_browser);
    MenuItem menuLayout = menu.findItem(R.id.action_menu_layout);
    MenuItem shareButton = menu.findItem(R.id.menu_item_share);
    MenuItem sortBy = menu.findItem(R.id.action_sort_by);

    replyButton.setVisible(true);
    openExternalButton.setVisible(true);
    menuLayout.setVisible(true);
    sortBy.setVisible(true);
    shareButton.setVisible(true);
    shareActionProvider = MenuItemCompat.getActionProvider(shareButton);

    MenuItem searchButton = menu.findItem(R.id.action_search);
    searchButton.setVisible(true);
    SearchView searchView = (SearchView) searchButton.getActionView();
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            Log.d(LOG_TAG, "query=" + newText);
            catalogAdapter.setFilterQueryProvider(new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return infiniteDbHelper.searchCatalogForThread(constraint.toString(), SettingsHelper.getSortByMethod(getContext()));
                }
            });
            catalogAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
项目:Ouroboros    文件:ThreadFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem goToBottomButton = menu.findItem(R.id.action_scroll_bottom);
    MenuItem goToTopButton = menu.findItem(R.id.action_scroll_top);
    MenuItem replyButton = menu.findItem(R.id.action_reply);
    MenuItem watchlistButton = menu.findItem(R.id.action_add_watchlist);
    MenuItem refreshButton = menu.findItem(R.id.action_refresh);
    MenuItem galleryButton = menu.findItem(R.id.action_gallery);
    MenuItem saveAllImagesButton = menu.findItem(R.id.action_save_all_images);
    MenuItem openExternalButton = menu.findItem(R.id.action_external_browser);
    MenuItem shareButton = menu.findItem(R.id.menu_item_share);
    MenuItem menuLayout = menu.findItem(R.id.action_menu_layout);

    MenuItem searchButton = menu.findItem(R.id.action_search);
    searchButton.setVisible(true);
    final SearchView searchView = (SearchView) searchButton.getActionView();
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            threadAdapter.setFilterQueryProvider(new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return infiniteDbHelper.searchThreadForString(constraint.toString(), resto);
                }
            });
            threadAdapter.getFilter().filter(newText);
            return true;
        }
    });

    MenuItemCompat.setOnActionExpandListener(searchButton, this);

    refreshButton.setVisible(true);
    goToBottomButton.setVisible(true);
    goToTopButton.setVisible(true);
    replyButton.setVisible(true);
    galleryButton.setVisible(true);
    saveAllImagesButton.setVisible(true);
    openExternalButton.setVisible(true);
    shareButton.setVisible(true);
    watchlistButton.setVisible(true);
    menuLayout.setVisible(true);

    super.onCreateOptionsMenu(menu, inflater);
}
项目:hut    文件:ActionsAdapter.java   
public ActionsAdapter(Context c, final ActionsProvider.Category category, final ViewBinder viewBinder) {
    super(c, R.layout.item, App.actions().query(category, ""), COLUMNS, VIEWS);
    if (mMissingIcon == null) {
        mMissingIcon = c.getPackageManager().getDefaultActivityIcon();
    }
    setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return App.actions().query(category, constraint.toString());
        }
    });
    setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            if (view instanceof ImageView) {
                final ImageView imageView = (ImageView) view;
                final String uri = cursor.getString(columnIndex);
                Drawable d = mCache.get(uri);
                if (d != null) {
                    imageView.setImageDrawable(d);
                } else {
                    imageView.setImageDrawable(null);
                    imageView.post(new Runnable() {
                        public void run() {
                            try {
                                Drawable drawable = null;
                                if (uri != null) {
                                    if (uri.startsWith("data:image/png;base64,")) {
                                        String b64 = uri.substring(uri.indexOf(",") + 1);
                                        byte[] raw = Base64.decode(b64, 0);
                                        drawable = new BitmapDrawable(BitmapFactory.decodeByteArray(raw, 0, raw.length));
                                    } else {
                                        InputStream inputStream = view.getContext().getContentResolver().openInputStream(Uri.parse(uri));
                                        drawable = Drawable.createFromStream(inputStream, uri);
                                    }
                                }
                                if (drawable != null) {
                                    mCache.put(uri, drawable);
                                } else {
                                    mCache.put(uri, mMissingIcon);
                                }
                                notifyDataSetChanged();
                            } catch (FileNotFoundException e) {
                                mCache.put(uri, mMissingIcon);
                            }
                        }
                    });
                }
                return true;
            }
            return viewBinder != null && viewBinder.setViewValue(view, cursor, columnIndex);
        }
    });
}
项目:MiBandDecompiled    文件:CursorAdapter.java   
public FilterQueryProvider getFilterQueryProvider()
{
    return mFilterQueryProvider;
}
项目:MiBandDecompiled    文件:CursorAdapter.java   
public void setFilterQueryProvider(FilterQueryProvider filterqueryprovider)
{
    mFilterQueryProvider = filterqueryprovider;
}
项目:MyCTFWriteUps    文件:CursorAdapter.java   
public FilterQueryProvider getFilterQueryProvider()
{
    return mFilterQueryProvider;
}
项目:MyCTFWriteUps    文件:CursorAdapter.java   
public void setFilterQueryProvider(FilterQueryProvider filterqueryprovider)
{
    mFilterQueryProvider = filterqueryprovider;
}
项目:Thrift-box    文件:CursorTreeAdapter.java   
/**
 * @see android.widget.CursorAdapter#getFilterQueryProvider()
 */
public FilterQueryProvider getFilterQueryProvider() {
    return mFilterQueryProvider;
}
项目:Thrift-box    文件:CursorTreeAdapter.java   
/**
 * @see android.widget.CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider)
 */
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    mFilterQueryProvider = filterQueryProvider;
}
项目:kidsdialer    文件:FavoritesManagerActivity.java   
private void populateContactList() {
    // Build adapter with contact entries
    /*
     * while (cursor.moveToNext()) {
     * 
     * String contactId =
     * cursor.getString(cursor.getColumnIndex(ContactsContract
     * .Contacts._ID)); String contactName =
     * cursor.getString(cursor.getColumnIndex
     * (ContactsContract.Contacts.DISPLAY_NAME)); //String contactPhone =
     * cursor
     * .getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds
     * .Phone.NUMBER)); Log.d(TAG,contactId + " "+ contactName+ " "); String
     * hasPhone =
     * cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts
     * .HAS_PHONE_NUMBER)); if (Integer.parseInt(hasPhone) > 0 ) { // You
     * know it has a number so now query it like this Cursor phones =
     * getContentResolver().query(
     * ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
     * ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,
     * null, null); while (phones.moveToNext()) { String phoneNumber =
     * phones.getString(phones.getColumnIndex(
     * ContactsContract.CommonDataKinds.Phone.NUMBER ) ) ;
     * Log.d(TAG,"   "+phoneNumber); } phones.close(); } }
     */

    String[] fields = new String[] { ContactsContract.Data.DISPLAY_NAME,
            Phone.NUMBER };

    String[] favoritesFields = new String[] { TableDefs.CONTACT_NAME,
            TableDefs.CONTACT_PHONES };

    contactsCursor = getContacts(null);

    mContactListAdapter = new ListCursorAdapter // SimpleCursorAdapter
    (this, R.layout.contact_entry_v, contactsCursor, fields, new int[] {
            R.id.contactEntryText, R.id.contactPhoneText });

    FilterQueryProvider filterQueryProvider = new FilterQueryProvider() {
           public Cursor runQuery(CharSequence constraint) {
               // Search for states whose names begin with the specified letters.
               Cursor cursor = getContacts(
                        (constraint != null ? constraint.toString() : null)
                       );
               return cursor;
           }
       };

    mContactListAdapter.setFilterQueryProvider( filterQueryProvider );

    mContactList.setOnItemClickListener(new ContactOnItemClickListener());
    mContactList.setAdapter(mContactListAdapter);

    mFavoriteDataProvider = new FavoriteDataProvider(this);

    mFavoritesListAdapter = new SimpleCursorAdapter(this,
            R.layout.contact_entry_v,
            mFavoriteDataProvider.getFavoriteCursor(), favoritesFields,
            new int[] { R.id.contactEntryText, R.id.contactPhoneText },
            SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    mFavoritetList
            .setOnItemClickListener(new FavoritesOnItemClickListener());
    mFavoritetList.setAdapter(mFavoritesListAdapter);
}
项目:SuperSelector    文件:RecyclerViewCursorAdapter.java   
/**
 * Returns the query filter provider used for filtering. When the
 * provider is null, no filtering occurs.
 *
 * @return the current filter query provider or null if it does not exist
 * @see #setFilterQueryProvider(FilterQueryProvider)
 * @see #runQueryOnBackgroundThread(CharSequence)
 */
public FilterQueryProvider getFilterQueryProvider() {
    return mFilterQueryProvider;
}
项目:SuperSelector    文件:RecyclerViewCursorAdapter.java   
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link FilterQueryProvider#runQuery(CharSequence)}
 * method is invoked when filtering is requested by a client of
 * this adapter.
 *
 * @param filterQueryProvider the filter query provider or null to remove it
 * @see #getFilterQueryProvider()
 * @see #runQueryOnBackgroundThread(CharSequence)
 */
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    mFilterQueryProvider = filterQueryProvider;
}
项目:News24x7-news-from-every-part-of-the-world    文件:CursorRecyclerViewAdapter.java   
/**
 * Returns the query filter provider used for filtering. When the
 * provider is null, no filtering occurs.
 *
 * @return the current filter query provider or null if it does not exist
 *
 * @see #setFilterQueryProvider(android.widget.FilterQueryProvider)
 * @see #runQueryOnBackgroundThread(CharSequence)
 */
public FilterQueryProvider getFilterQueryProvider() {
    return mFilterQueryProvider;
}