Browse Source

Fixes #66 where transdroid would crash when clicking a search result that does not point to a .torrent url.

pull/82/head
Eric Kok 11 years ago
parent
commit
10fa881e89
  1. 1
      core/res/values/strings.xml
  2. 7
      core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

1
core/res/values/strings.xml

@ -372,6 +372,7 @@
<string name="error_invalid_port_number">Port number is always numeric</string> <string name="error_invalid_port_number">Port number is always numeric</string>
<string name="error_invalid_directory">Directory paths end with a / or \</string> <string name="error_invalid_directory">Directory paths end with a / or \</string>
<string name="error_invalid_timeout">Timeout can not be empty and is a positive number</string> <string name="error_invalid_timeout">Timeout can not be empty and is a positive number</string>
<string name="error_notorrentfile">The search result does not link to a .torrent file</string>
<string name="error_no_url_enclosure">The RSS feed item didn\'t provide an URL enclosure or link tag pointing to the .torrent file</string> <string name="error_no_url_enclosure">The RSS feed item didn\'t provide an URL enclosure or link tag pointing to the .torrent file</string>
<string name="error_no_link">The RSS feed item does not provide a link to browse to</string> <string name="error_no_link">The RSS feed item does not provide a link to browse to</string>
<string name="error_norssfeed">URL is not a (valid) RSS feed</string> <string name="error_norssfeed">URL is not a (valid) RSS feed</string>

7
core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -34,6 +34,7 @@ import org.transdroid.core.app.search.SearchResult;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.SystemSettings_; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity_; import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.NavigationHelper_; import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
@ -51,6 +52,8 @@ import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.SherlockListView; import com.actionbarsherlock.view.SherlockListView;
import com.actionbarsherlock.view.SherlockListView.MultiChoiceModeListenerCompat; import com.actionbarsherlock.view.SherlockListView.MultiChoiceModeListenerCompat;
import de.keyboardsurfer.android.widget.crouton.Crouton;
/** /**
* Fragment that lists the items in a specific RSS feed * Fragment that lists the items in a specific RSS feed
* @author Eric Kok * @author Eric Kok
@ -122,6 +125,10 @@ public class SearchResultsFragment extends SherlockFragment {
@ItemClick(resName = "searchresults_list") @ItemClick(resName = "searchresults_list")
protected void onItemClicked(SearchResult item) { protected void onItemClicked(SearchResult item) {
if (item.getTorrentUrl() == null) {
Crouton.showText(getActivity(), R.string.error_notorrentfile, NavigationHelper.CROUTON_ERROR_STYLE);
return;
}
// Don't broadcast this intent; we can safely assume this is intended for Transdroid only // Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(getActivity()).get(); Intent i = TorrentsActivity_.intent(getActivity()).get();
i.setData(Uri.parse(item.getTorrentUrl())); i.setData(Uri.parse(item.getTorrentUrl()));

Loading…
Cancel
Save