Example usage for android.app SearchManager FLAG_QUERY_REFINEMENT

List of usage examples for android.app SearchManager FLAG_QUERY_REFINEMENT

Introduction

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

Prototype

int FLAG_QUERY_REFINEMENT

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

Click Source Link

Document

Flag to specify that the entry can be used for query refinement, i.e., the query text in the search field can be replaced with the text in this entry, when a query refinement icon is clicked.

Usage

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

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ChildViewCache views = (ChildViewCache) view.getTag();

    contact = PadContacts.getPadContact(Long.parseLong(cursor.getString(mIconName2Col)));
    int flags = 0;
    if (mFlagsCol != INVALID_INDEX) {
        flags = cursor.getInt(mFlagsCol);
    }//from  w w  w .java  2  s  . co  m
    if (views.mText1 != null) {
        String text1 = getStringOrNull(cursor, mText1Col);
        setViewText(views.mText1, text1);
    }
    if (views.mText2 != null) {
        // First check TEXT_2_URL
        CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
        if (text2 != null) {
            text2 = formatUrl(text2);
        } else {
            text2 = getStringOrNull(cursor, mText2Col);
        }

        // If no second line of text is indicated, allow the first line of text
        // to be up to two lines if it wants to be.
        if (TextUtils.isEmpty(text2)) {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(false);
                views.mText1.setMaxLines(2);
            }
        } else {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(true);
                views.mText1.setMaxLines(1);
            }
        }
        setViewText(views.mText2, text2);
    }

    if (views.mIcon1 != null) {
        setViewDrawable(views.mIcon1, getIcon1(cursor), View.GONE);
    }
    if (views.mIcon2 != null) {
        setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
    }
    if (mQueryRefinement == REFINE_ALL
            || (mQueryRefinement == REFINE_BY_ENTRY && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
        views.mIconRefine.setVisibility(View.VISIBLE);
        views.mIconRefine.setTag(views.mText1.getText());
        views.mIconRefine.setOnClickListener(this);
    } else {
        views.mIconRefine.setVisibility(View.GONE);
    }
}

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

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ChildViewCache views = (ChildViewCache) view.getTag();

    int flags = 0;
    if (mFlagsCol != INVALID_INDEX) {
        flags = cursor.getInt(mFlagsCol);
    }//ww w .  ja  va  2  s.co m
    if (views.mText1 != null) {
        String text1 = getStringOrNull(cursor, mText1Col);
        setViewText(views.mText1, text1);
    }
    if (views.mText2 != null) {
        // First check TEXT_2_URL
        CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
        if (text2 != null) {
            text2 = formatUrl(text2);
        } else {
            text2 = getStringOrNull(cursor, mText2Col);
        }

        // If no second line of text is indicated, allow the first line of text
        // to be up to two lines if it wants to be.
        if (TextUtils.isEmpty(text2)) {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(false);
                views.mText1.setMaxLines(2);
            }
        } else {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(true);
                views.mText1.setMaxLines(1);
            }
        }
        setViewText(views.mText2, text2);
    }

    if (views.mIcon1 != null) {
        setViewDrawable(views.mIcon1, getIcon1(cursor), View.INVISIBLE);
    }
    if (views.mIcon2 != null) {
        setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
    }
    if (mQueryRefinement == REFINE_ALL
            || (mQueryRefinement == REFINE_BY_ENTRY && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
        views.mIconRefine.setVisibility(View.VISIBLE);
        views.mIconRefine.setTag(views.mText1.getText());
        views.mIconRefine.setOnClickListener(this);
    } else {
        views.mIconRefine.setVisibility(View.GONE);
    }
}

From source file:com.tandong.sa.sherlock.widget.SuggestionsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ChildViewCache views = (ChildViewCache) view.getTag();
    this.ct = context;
    int flags = 0;
    if (mFlagsCol != INVALID_INDEX) {
        flags = cursor.getInt(mFlagsCol);
    }//from www  . j a  v a2s .  com
    if (views.mText1 != null) {
        String text1 = getStringOrNull(cursor, mText1Col);
        setViewText(views.mText1, text1);
    }
    if (views.mText2 != null) {
        // First check TEXT_2_URL
        CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
        if (text2 != null) {
            text2 = formatUrl(text2);
        } else {
            text2 = getStringOrNull(cursor, mText2Col);
        }

        // If no second line of text is indicated, allow the first line of
        // text
        // to be up to two lines if it wants to be.
        if (TextUtils.isEmpty(text2)) {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(false);
                views.mText1.setMaxLines(2);
            }
        } else {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(true);
                views.mText1.setMaxLines(1);
            }
        }
        setViewText(views.mText2, text2);
    }

    if (views.mIcon1 != null) {
        setViewDrawable(views.mIcon1, getIcon1(cursor), View.INVISIBLE);
    }
    if (views.mIcon2 != null) {
        setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
    }
    if (mQueryRefinement == REFINE_ALL
            || (mQueryRefinement == REFINE_BY_ENTRY && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
        views.mIconRefine.setVisibility(View.VISIBLE);
        views.mIconRefine.setTag(views.mText1.getText());
        views.mIconRefine.setOnClickListener(this);
    } else {
        views.mIconRefine.setVisibility(View.GONE);
    }
}