Correctly handle r/popular and r/all links.

This commit is contained in:
Alex Ning 2020-11-22 00:13:00 +08:00
parent 2c194d5120
commit ae213259b3
2 changed files with 5 additions and 24 deletions

View File

@ -139,20 +139,11 @@ public class LinkResolverActivity extends AppCompatActivity {
deepLinkError(uri);
}
} else if (path.matches(SUBREDDIT_PATTERN)) {
String subredditName = path.substring(3);
if (subredditName.equals("popular") || subredditName.equals("all")) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_POST_TYPE, subredditName);
intent.putExtra(MainActivity.EXTRA_MESSSAGE_FULLNAME, messageFullname);
intent.putExtra(MainActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3));
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
} else if (path.matches(USER_PATTERN)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, segments.get(1));

View File

@ -112,7 +112,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, RandomBottomSheetFragment.RandomOptionSelectionCallback {
static final String EXTRA_POST_TYPE = "EPT";
static final String EXTRA_MESSSAGE_FULLNAME = "ENF";
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
@ -844,15 +843,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
});
if (getIntent().hasExtra(EXTRA_POST_TYPE)) {
String type = getIntent().getStringExtra(EXTRA_POST_TYPE);
if (type != null && type.equals("popular")) {
viewPager2.setCurrentItem(1);
} else {
viewPager2.setCurrentItem(2);
}
}
loadUserData();
if (mAccessToken != null) {