android.widget.FilterQueryProvider Java Examples

The following examples show how to use android.widget.FilterQueryProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchSuggestionAdapter.java    From KinoCast with MIT License 6 votes vote down vote up
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;
        }
    });
}
 
Example #2
Source File: AutoComplete4.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@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);
}
 
Example #3
Source File: Collins.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #4
Source File: WebsterLearners.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: Ode2.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #6
Source File: CollinsEnEn.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #7
Source File: CustomDictionary.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout, null,
                    new String[] {ExternalDatabase.getHeadwordColumnName()},
                    new int[] {android.R.id.text1},
                    0
                    );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return mDatabase.getFilterCursor(mDictId, constraint.toString());
                }
            }
    );

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

    return adapter;
}
 
Example #8
Source File: LyricCursorAdapter.java    From LyricHere with Apache License 2.0 5 votes vote down vote up
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());
        }
    });
}
 
Example #9
Source File: CursorAdapter.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public FilterQueryProvider getFilterQueryProvider()
{
    return mFilterQueryProvider;
}
 
Example #10
Source File: CursorAdapter.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void setFilterQueryProvider(FilterQueryProvider filterqueryprovider)
{
    mFilterQueryProvider = filterqueryprovider;
}
 
Example #11
Source File: CursorAdapter.java    From letv with Apache License 2.0 4 votes vote down vote up
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
 
Example #12
Source File: ThreadFragment.java    From Ouroboros with GNU General Public License v3.0 4 votes vote down vote up
@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);
}
 
Example #13
Source File: CatalogFragment.java    From Ouroboros with GNU General Public License v3.0 4 votes vote down vote up
@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;
        }
    });
}
 
Example #14
Source File: CursorAdapter.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
 
Example #15
Source File: ShareTrackDialogFragment.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
protected Dialog createDialog() {
  FragmentActivity fragmentActivity = getActivity();
  accounts = AccountManager.get(fragmentActivity).getAccountsByType(Constants.ACCOUNT_TYPE);

  if (accounts.length == 0) {
    return new AlertDialog.Builder(fragmentActivity).setMessage(
        R.string.send_google_no_account_message).setTitle(R.string.send_google_no_account_title)
        .setPositiveButton(R.string.generic_ok, null).create();
  }

  // Get all the views
  View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null);
  publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public);
  inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
  multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
      R.id.share_track_emails);
  accountSpinner = (Spinner) view.findViewById(R.id.share_track_account);
  
  // Setup publicCheckBox
  publicCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_public_key,
      PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT));

  // Setup inviteCheckBox
  inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      multiAutoCompleteTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
    }
  });
  inviteCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_invite_key,
      PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT));

  // Setup multiAutoCompleteTextView
  multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
  SimpleCursorAdapter adapter = new SimpleCursorAdapter(fragmentActivity,
      R.layout.add_emails_item, getAutoCompleteCursor(fragmentActivity, null), new String[] {
          ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA },
      new int[] { android.R.id.text1, android.R.id.text2 }, 0);
  adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
      @Override
    public CharSequence convertToString(Cursor cursor) {
      int index = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
      return cursor.getString(index).trim();
    }
  });
  adapter.setFilterQueryProvider(new FilterQueryProvider() {
      @Override
    public Cursor runQuery(CharSequence constraint) {
      return getAutoCompleteCursor(getActivity(), constraint);
    }
  });
  multiAutoCompleteTextView.setAdapter(adapter);

  // Setup accountSpinner
  accountSpinner.setVisibility(accounts.length > 1 ? View.VISIBLE : View.GONE);
  AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts);
  
  return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
      R.string.generic_cancel, null)
      .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
          @Override
        public void onClick(DialogInterface dialog, int which) {
          FragmentActivity context = getActivity();
          if (!publicCheckBox.isChecked() && !inviteCheckBox.isChecked()) {
            Toast.makeText(context, R.string.share_track_no_selection, Toast.LENGTH_LONG).show();
            return;
          }
          String acl = multiAutoCompleteTextView.getText().toString().trim();
          if (!publicCheckBox.isChecked() && acl.equals("")) {
            Toast.makeText(context, R.string.share_track_no_emails, Toast.LENGTH_LONG).show();
            return;
          }
          PreferencesUtils.setBoolean(
              context, R.string.share_track_public_key, publicCheckBox.isChecked());
          PreferencesUtils.setBoolean(
              context, R.string.share_track_invite_key, inviteCheckBox.isChecked());
          Account account = accounts.length > 1 ? accounts[accountSpinner
              .getSelectedItemPosition()]
              : accounts[0];
          AccountUtils.updateShareTrackAccountPreference(context, account);
          caller.onShareTrackDone(
              getArguments().getLong(KEY_TRACK_ID), publicCheckBox.isChecked(), acl, account);
        }
      }).setTitle(R.string.share_track_title).setView(view).create();
}
 
Example #16
Source File: CursorAdapter.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
 
Example #17
Source File: CursorAdapter.java    From letv with Apache License 2.0 4 votes vote down vote up
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
 
Example #18
Source File: CursorAdapter.java    From ExRecyclerViewLibrary with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #19
Source File: CursorAdapter.java    From ExRecyclerViewLibrary with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: CursorAdapter.java    From guideshow with MIT License 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #21
Source File: CursorAdapter.java    From guideshow with MIT License 2 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source File: CursorAdapter.java    From V.FlyoutTest with MIT License 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #23
Source File: CursorAdapter.java    From V.FlyoutTest with MIT License 2 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source File: CursorAdapter.java    From v2ex with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source File: CursorAdapter.java    From v2ex with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #26
Source File: CursorAdapter.java    From android-recipes-app with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #27
Source File: CursorAdapter.java    From android-recipes-app with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #28
Source File: CursorRecyclerAdapter.java    From android-atleap with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}
 
Example #29
Source File: CursorRecyclerAdapter.java    From android-atleap with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: BaseAbstractRecycleCursorAdapter.java    From AppCodeArchitecture with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the query filter provider used to filter the current Cursor.
 * The provider's
 * {@link android.widget.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;
}