Example usage for android.app SearchManager SUGGEST_COLUMN_TEXT_2

List of usage examples for android.app SearchManager SUGGEST_COLUMN_TEXT_2

Introduction

In this page you can find the example usage for android.app SearchManager SUGGEST_COLUMN_TEXT_2.

Prototype

String SUGGEST_COLUMN_TEXT_2

To view the source code for android.app SearchManager SUGGEST_COLUMN_TEXT_2.

Click Source Link

Document

Column name for suggestions cursor.

Usage

From source file:com.dvdprime.mobile.android.adapter.DocumentSuggestionsAdapter.java

public static MatrixCursor getCursor(String query) {
    //  ? ?? /* ww  w .ja  v  a2 s . co  m*/
    final String[] COLUMNS = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
            SearchManager.SUGGEST_COLUMN_TEXT_2 };

    MatrixCursor cursor = new MatrixCursor(COLUMNS);
    cursor.addRow(new Object[] { 1, query, " " });
    cursor.addRow(new Object[] { 2, query, "ID " });
    cursor.addRow(new Object[] { 6, query, " " });
    cursor.addRow(new Object[] { 4, query, "? " });
    cursor.addRow(new Object[] { 7, query, "  " });

    return cursor;
}

From source file:com.dvdprime.mobile.android.adapter.DocumentSuggestionsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView tv1 = (TextView) view.findViewById(android.R.id.text1);
    tv1.setText(cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1)));
    TextView tv2 = (TextView) view.findViewById(android.R.id.text2);
    tv2.setTextAppearance(context, R.style.DarkGrayBaseSmallText);
    tv2.setText(cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2)));
}

From source file:com.dmsl.anyplace.nav.AnyPlaceSeachingHelper.java

public static Cursor prepareSearchViewCursor(List<? extends IPoisClass> places) {
    String req_columns[] = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
            SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA };
    MatrixCursor mcursor = new MatrixCursor(req_columns);
    int i = 0;//  w  ww.ja v a 2s . c  o m
    if (places != null) {
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.registerTypeAdapter(IPoisClass.class, new IPoisClass.MyInterfaceAdapter());
        Gson gson = gsonBuilder.create();
        for (IPoisClass p : places) {
            mcursor.addRow(new String[] { Integer.toString(i++), p.name(),
                    p.description().equals("") ? "no description" : p.description(),
                    gson.toJson(p, IPoisClass.class) });
        }
    }
    return mcursor;
}

From source file:com.dvdprime.mobile.android.adapter.DocumentSuggestionsAdapter.java

public static MatrixCursor getCursor2(String query) {
    //  ? ?? /*  w  w  w. j  a v a 2 s . c o  m*/
    final String[] COLUMNS = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
            SearchManager.SUGGEST_COLUMN_TEXT_2 };

    MatrixCursor cursor = new MatrixCursor(COLUMNS);
    cursor.addRow(new Object[] { 1, query, " " });
    cursor.addRow(new Object[] { 2, query, "ID " });
    cursor.addRow(new Object[] { 4, query, "? " });
    cursor.addRow(new Object[] { 7, query, "  " });

    return cursor;
}

From source file:com.google.android.demos.jamendo.widget.SearchAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    bindTextView(view, cursor, R.id.text1, SearchManager.SUGGEST_COLUMN_TEXT_1);
    bindTextView(view, cursor, R.id.text2, SearchManager.SUGGEST_COLUMN_TEXT_2);
    bindImageView(view, cursor, R.id.icon, SearchManager.SUGGEST_COLUMN_ICON_2);
}

From source file:au.com.cybersearch2.classyfy.ClassyfyLogic.java

/**
 * Perform content provider query for fast text search, Must be executed on background thread. 
 * @param searchQuery Query string/*ww w .  j  a  v a2 s . c o  m*/
 * @return
 */
public List<ListItem> doSearchQuery(String searchQuery) {
    // Perform the search, passing in the search query as an argument to the Cursor Loader
    SuggestionCursorParameters params = new SuggestionCursorParameters(searchQuery,
            ClassyFySearchEngine.LEX_CONTENT_URI, ClassyFyProvider.SEARCH_RESULTS_LIMIT);

    ContentResolver contentResolver = context.getContentResolver();
    Cursor cursor = contentResolver.query(params.getUri(), params.getProjection(), params.getSelection(),
            params.getSelectionArgs(), params.getSortOrder());
    List<ListItem> fieldList = new ArrayList<ListItem>();
    int nameColumnId = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1);
    int valueColumnId = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_2);
    // Id column name set in android.support.v4.widget.CursorAdaptor
    int idColumnId = cursor.getColumnIndexOrThrow("_id");
    if (cursor.getCount() > 0) {
        cursor.moveToPosition(-1);
        while (cursor.moveToNext()) {
            String name = cursor.getString(nameColumnId);
            String value = cursor.getString(valueColumnId);
            long id = cursor.getLong(idColumnId);
            fieldList.add(new ListItem(name, value, id));
        }
    }
    cursor.close();
    return fieldList;
}

From source file:com.google.android.demos.jamendo.app.SearchActivity.java

/** {@inheritDoc} */
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Intent intent = getIntent();/*from   w  ww .j  a v a  2  s .c o  m*/
    String query = intent.getStringExtra(SearchManager.QUERY);

    Uri.Builder builder = JamendoContract.AUTHORITY_URI.buildUpon();
    builder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
    builder.appendPath(query);
    Uri uri = builder.build();
    String[] projection = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_ICON_2,
            SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2 };
    String selection = JamendoContract.PARAM_IMAGE_SIZE + "=" + mImageSize;
    String[] selectionArgs = null;
    String sortOrder = null;
    return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder);
}

From source file:com.aboveware.sms.contacts.ContactSuggestionsAdapter.java

/**
 * Cache columns.//from  w  w w.j a va 2  s .co m
 */
@SuppressLint("InlinedApi")
@Override
public void changeCursor(Cursor c) {
    if (DBG)
        Log.d(LOG_TAG, "changeCursor(" + c + ")");

    if (mClosed) {
        Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
        if (c != null)
            c.close();
        return;
    }

    try {
        super.changeCursor(c);

        if (c != null) {
            mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
            mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
            mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
            c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
            mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);
            mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS);
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "error changing cursor and caching columns", e);
    }
}

From source file:android.support.v7.widget.SuggestionsAdapter.java

/**
 * Cache columns./*  www. ja  va 2  s. c  om*/
 */
@Override
public void changeCursor(Cursor c) {
    if (DBG)
        Log.d(LOG_TAG, "changeCursor(" + c + ")");

    if (mClosed) {
        Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
        if (c != null)
            c.close();
        return;
    }

    try {
        super.changeCursor(c);

        if (c != null) {
            mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
            mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
            mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
            mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
            mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);
            mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS);
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "error changing cursor and caching columns", e);
    }
}

From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivityTest.java

@Test
public void test_OnCreate() throws Exception {
    titleSearchResultsActivity = (TitleSearchResultsActivity) controller.create().get();
    assertThat(titleSearchResultsActivity.adapter).isNotNull();
    verify(titleSearchResultsFragment).setListAdapter(eq(simpleCursorAdapter));
    CursorAdapaterParameters params = new CursorAdapaterParameters();
    assertThat(params.getLayout()).isEqualTo(android.R.layout.simple_list_item_2);
    assertThat(params.getCursor()).isNull();
    assertThat(params.getUiBindFrom()).isEqualTo(
            new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2 });
    assertThat(params.getUiBindTo()).isEqualTo(new int[] { android.R.id.text1, android.R.id.text2 });
    assertThat(params.getFlags()).isEqualTo(0);
    assertThat(((TestTitleSearchResultsActivity) titleSearchResultsActivity).titleSearchResultsFragmentId)
            .isEqualTo(R.id.title_search_results_fragment);
}