From 0208dab4299ed4a80dc340b82173117af9c44652 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Wed, 24 Jul 2013 15:59:28 +0200 Subject: [PATCH] Fix search suggestions and tweak result list appearance. --- core/res/layout/list_item_searchresult.xml | 2 +- core/res/menu/activity_search.xml | 10 +++++----- core/res/xml/searchable.xml | 9 ++++----- .../org/transdroid/core/app/search/SearchHelper.java | 9 +++++++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core/res/layout/list_item_searchresult.xml b/core/res/layout/list_item_searchresult.xml index c4d1c530..f9c62e3c 100644 --- a/core/res/layout/list_item_searchresult.xml +++ b/core/res/layout/list_item_searchresult.xml @@ -51,7 +51,7 @@ android:layout_height="wrap_content" android:layout_alignBaseline="@id/leechers_text" android:layout_toRightOf="@id/size_text" - android:layout_marginRight="@dimen/margin_default" + android:layout_marginLeft="@dimen/margin_default" android:textIsSelectable="false" android:textSize="@dimen/text_small" /> diff --git a/core/res/menu/activity_search.xml b/core/res/menu/activity_search.xml index dc460ae9..3e2ad945 100644 --- a/core/res/menu/activity_search.xml +++ b/core/res/menu/activity_search.xml @@ -1,15 +1,15 @@ - + - - \ No newline at end of file + android:searchSuggestAuthority="org.transdroid.core.gui.search.TorrentSearchHistoryProvider" + android:searchSuggestThreshold="0" + android:searchSuggestSelection=" ?" /> diff --git a/core/src/org/transdroid/core/app/search/SearchHelper.java b/core/src/org/transdroid/core/app/search/SearchHelper.java index d01c9d9c..de0a40d8 100644 --- a/core/src/org/transdroid/core/app/search/SearchHelper.java +++ b/core/src/org/transdroid/core/app/search/SearchHelper.java @@ -57,7 +57,7 @@ public class SearchHelper { // Torrent Search package is not yet installed return null; } - + // Query the available in-app torrent search sites Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); if (cursor.moveToFirst()) { @@ -81,7 +81,8 @@ public class SearchHelper { * @param query The search query to pass to the torrent site * @param site The site to search, as retrieved from the TorrentSitesProvider, or null if the Torrent Search package * @param sortBy.name() The sort order to request from the torrent site, if supported - * @return A list of torrent search results as POJOs, or null if the Torrent Search package is not installed + * @return A list of torrent search results as POJOs, or null if the Torrent Search package is not installed or + * there is no internet connection */ public ArrayList search(String query, SearchSite site, SearchSortOrder sortBy) { @@ -95,6 +96,10 @@ public class SearchHelper { cursor = context.getContentResolver().query(uri, null, "SITE = ?", new String[] { site.getKey() }, sortBy.name()); } + if (cursor == null) { + // The content provider could not load any content (for example when there is no connection) + return null; + } if (cursor.moveToFirst()) { ArrayList results = new ArrayList(); do {