Fixed handling of wiki pages

LinkResolverActivity now handles wiki pages other than index and their subpages.
This commit is contained in:
andrewrasch 2021-09-21 23:50:30 -04:00
parent 5cfe8a6016
commit 2d5829830e
2 changed files with 5 additions and 3 deletions

View File

@ -49,7 +49,7 @@ public class LinkResolverActivity extends AppCompatActivity {
private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?";
private static final String IMGUR_IMAGE_PATTERN = "/\\w+/?";
private static final String RPAN_BROADCAST_PATTERN = "/rpan/r/[\\w-]+/\\w+/?\\w+/?";
private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)/?\\w+";
private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)?(?:/\\w+)+";
@Inject
@Named("default")
@ -173,8 +173,10 @@ public class LinkResolverActivity extends AppCompatActivity {
deepLinkError(uri);
}
} else if (path.matches(WIKI_PATTERN)) {
final String wikiPage = path.substring(path.lastIndexOf("/wiki/") + 6);
Intent intent = new Intent(this, WikiActivity.class);
intent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, segments.get(1));
intent.putExtra(WikiActivity.EXTRA_WIKI_PATH, wikiPage);
startActivity(intent);
} else if (path.matches(SUBREDDIT_PATTERN)) {
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);

View File

@ -71,7 +71,7 @@ import retrofit2.Retrofit;
public class WikiActivity extends BaseActivity {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
public static final String WIKI_PATH = "WP";
public static final String EXTRA_WIKI_PATH = "EWP";
private static final String WIKI_MARKDOWN_STATE = "WMS";
@BindView(R.id.coordinator_layout_comment_wiki_activity)
@ -282,7 +282,7 @@ public class WikiActivity extends BaseActivity {
Glide.with(this).clear(mFetchWikiInfoImageView);
mFetchWikiInfoLinearLayout.setVisibility(View.GONE);
retrofit.create(RedditAPI.class).getWiki(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME)).enqueue(new Callback<String>() {
retrofit.create(RedditAPI.class).getWikiPage(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME), getIntent().getStringExtra(EXTRA_WIKI_PATH)).enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {