Skip to content

Commit

Permalink
Fixed bug with huge "load more comments" links
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Sep 1, 2016
1 parent 3cb49cd commit 7c07d7b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Preference to use un-shortened link for "Share Comments" (thanks to fhtagn)
Preference for cache storage location (thanks to ShadowNinja)
Preference to set pinned subreddit sort order (thanks to chippen)
For albums with only one image, the image is now shown immediately
Fixed bug with huge "load more comments" links

73/1.9.5.1
Comment swipe actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -82,13 +81,11 @@ public void onCreate(final Bundle savedInstanceState) {
final Intent intent = getIntent();
mSearchString = intent.getStringExtra(EXTRA_SEARCH_STRING);

final ArrayList<String> urls = intent.getStringArrayListExtra("urls");
final ArrayList<String> commentIds = intent.getStringArrayListExtra("commentIds");
final String postId = intent.getStringExtra("postId");

for(final String url : urls) {
final RedditURLParser.RedditURL redditURL = RedditURLParser.parseProbableCommentListing(Uri.parse(url));
if(redditURL != null) {
mUrls.add(redditURL);
}
for(final String commentId : commentIds) {
mUrls.add(PostCommentListingURL.forPostId(postId).commentId(commentId));
}

doRefresh(RefreshableFragment.COMMENTS, false, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public LoadMoreCommentsView(

mCommentListingURL = commentListingURL;

// TODO setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

setOrientation(VERTICAL);

final View divider = new View(context);
Expand Down Expand Up @@ -101,14 +99,24 @@ public LoadMoreCommentsView(
setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
final ArrayList<String> urls = new ArrayList<>(16);
for(final PostCommentListingURL url : mItem.asLoadMore().getMoreUrls(mCommentListingURL)) {
urls.add(url.toString());
}

final Intent intent = new Intent(context, MoreCommentsListingActivity.class);
intent.putStringArrayListExtra("urls", urls);
context.startActivity(intent);
if(mCommentListingURL.pathType() == RedditURLParser.POST_COMMENT_LISTING_URL) {

final PostCommentListingURL listingUrl = mCommentListingURL.asPostCommentListURL();

final ArrayList<String> commentIds = new ArrayList<>(16);
for(final PostCommentListingURL url : mItem.asLoadMore().getMoreUrls(mCommentListingURL)) {
commentIds.add(url.commentId);
}

final Intent intent = new Intent(context, MoreCommentsListingActivity.class);
intent.putExtra("postId", listingUrl.postId);
intent.putStringArrayListExtra("commentIds", commentIds);
context.startActivity(intent);

} else {
General.quickToast(context, R.string.load_more_comments_failed_unknown_url_type);
}
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -889,4 +889,7 @@
<string name="sort_pinned_subreddit_name">By Name</string>
<string name="sort_pinned_subreddit_date">By Added Date</string>

<!-- 2016-09-01 -->
<string name="load_more_comments_failed_unknown_url_type">Cannot load more comments: unknown URL type.</string>

</resources>

0 comments on commit 7c07d7b

Please sign in to comment.