Skip to content

Commit

Permalink
Merge pull request #202 from chaitan94/master
Browse files Browse the repository at this point in the history
Fixes #201: Search on a subreddit twice doesn't work correctly
  • Loading branch information
QuantumBadger committed Jan 26, 2015
2 parents 0808fcc + c7cb8ef commit e14c767
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void onClick(DialogInterface dialog, int which) {

final SearchPostListURL url;

if(controller != null && controller.isSubreddit()) {
if(controller != null && (controller.isSubreddit() || controller.isSubredditSearchResults())) {
url = SearchPostListURL.build(controller.subredditCanonicalName(), query);
} else {
url = SearchPostListURL.build(null, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public final boolean isSubreddit() {
&& url.asSubredditPostListURL().type == SubredditPostListURL.Type.SUBREDDIT;
}

public final boolean isSubredditSearchResults() {
return url.pathType() == RedditURLParser.PathType.SearchPostListingURL
&& url.asSearchPostListURL().subreddit != null;
}

public final String subredditCanonicalName() {

if(url.pathType() == RedditURLParser.PathType.SubredditPostListingURL
Expand All @@ -93,6 +98,13 @@ public final String subredditCanonicalName() {
} catch(RedditSubreddit.InvalidSubredditNameException e) {
throw new RuntimeException(e);
}
} else if(url.pathType() == RedditURLParser.PathType.SearchPostListingURL
&& url.asSearchPostListURL().subreddit != null) {
try {
return RedditSubreddit.getCanonicalName(url.asSearchPostListURL().subreddit);
} catch(RedditSubreddit.InvalidSubredditNameException e) {
throw new RuntimeException(e);
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public final SubredditPostListURL asSubredditPostListURL() {
return (SubredditPostListURL)this;
}

public final SearchPostListURL asSearchPostListURL() {
return (SearchPostListURL)this;
}

public final UserPostListingURL asUserPostListURL() {
return (UserPostListingURL)this;
}
Expand Down

0 comments on commit e14c767

Please sign in to comment.