Example usage for android.app SearchManager.OnCancelListener SearchManager.OnCancelListener

List of usage examples for android.app SearchManager.OnCancelListener SearchManager.OnCancelListener

Introduction

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

Prototype

SearchManager.OnCancelListener

Source Link

Usage

From source file:org.geometerplus.android.fbreader.FBReader.java

@Override
public boolean onSearchRequested() {
    final FBReaderApp.PopupPanel popup = myFBReaderApp.getActivePopup();
    myFBReaderApp.hideActivePopup();//  www  .ja  v  a 2  s.  co  m
    if (DeviceType.Instance().hasStandardSearchDialog()) {
        final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
        manager.setOnCancelListener(new SearchManager.OnCancelListener() {
            public void onCancel() {
                if (popup != null) {
                    myFBReaderApp.showPopup(popup.getId());
                }
                manager.setOnCancelListener(null);
            }
        });
        startSearch(myFBReaderApp.MiscOptions.TextSearchPattern.getValue(), true, null, false);
    } else {
        SearchDialogUtil.showDialog(this, FBReader.class,
                myFBReaderApp.MiscOptions.TextSearchPattern.getValue(), new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface di) {
                        if (popup != null) {
                            myFBReaderApp.showPopup(popup.getId());
                        }
                    }
                });
    }
    return true;
}