Handle alternative multireddit URL.

This commit is contained in:
Hermes Junior 2020-05-12 00:27:53 +02:00 committed by OHermesJunior
parent adf8fa4e6a
commit ccecc2b511

View File

@ -36,6 +36,7 @@ public class LinkResolverActivity extends AppCompatActivity {
private static final String USER_PATTERN = "/([uU]|user)/\\w+/{0,1}"; private static final String USER_PATTERN = "/([uU]|user)/\\w+/{0,1}";
private static final String SIDEBAR_PATTERN = "/[rR]/\\w+/about/sidebar"; private static final String SIDEBAR_PATTERN = "/[rR]/\\w+/about/sidebar";
private static final String MULTIREDDIT_PATTERN = "/user/\\w+/m/\\w+/{0,1}"; private static final String MULTIREDDIT_PATTERN = "/user/\\w+/m/\\w+/{0,1}";
private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?";
private static final String REDD_IT_POST_PATTERN = "/\\w+/{0,1}"; private static final String REDD_IT_POST_PATTERN = "/\\w+/{0,1}";
@Inject @Inject
@ -136,6 +137,13 @@ public class LinkResolverActivity extends AppCompatActivity {
Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class); Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class);
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_PATH, path); intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_PATH, path);
startActivity(intent); startActivity(intent);
} else if (path.matches(MULTIREDDIT_PATTERN_2)) {
String subredditName = path.substring(3);
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) { } else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
Intent intent = new Intent(this, ViewPostDetailActivity.class); Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1)); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));