Search in sources :

Example 1 with NetworkTree

use of org.geometerplus.fbreader.network.NetworkTree in project FBReaderJ by geometer.

the class NetworkSearchActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    final Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        final Bundle data = intent.getBundleExtra(SearchManager.APP_DATA);
        if (data != null) {
            final NetworkLibrary library = Util.networkLibrary(this);
            final NetworkTree.Key key = (NetworkTree.Key) data.getSerializable(NetworkLibraryActivity.TREE_KEY_KEY);
            final NetworkTree tree = library.getTreeByKey(key);
            if (tree instanceof SearchCatalogTree) {
                final SearchCatalogTree searchTree = (SearchCatalogTree) tree;
                final String pattern = intent.getStringExtra(SearchManager.QUERY);
                final MimeType mime = searchTree.getMimeType();
                if (MimeType.APP_ATOM_XML.weakEquals(mime)) {
                    searchTree.startItemsLoader(myNetworkContext, pattern);
                } else if (MimeType.TEXT_HTML.weakEquals(mime)) {
                    Util.openInBrowser(this, searchTree.getUrl(pattern));
                }
            }
        }
    }
    finish();
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) MimeType(org.geometerplus.zlibrary.core.util.MimeType) NetworkLibrary(org.geometerplus.fbreader.network.NetworkLibrary) SearchCatalogTree(org.geometerplus.fbreader.network.tree.SearchCatalogTree) NetworkTree(org.geometerplus.fbreader.network.NetworkTree)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NetworkLibrary (org.geometerplus.fbreader.network.NetworkLibrary)1 NetworkTree (org.geometerplus.fbreader.network.NetworkTree)1 SearchCatalogTree (org.geometerplus.fbreader.network.tree.SearchCatalogTree)1 MimeType (org.geometerplus.zlibrary.core.util.MimeType)1