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); deepLinkError(uri);
} }
} else if (path.matches(SUBREDDIT_PATTERN)) { } else if (path.matches(SUBREDDIT_PATTERN)) {
String subredditName = path.substring(3); Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
if (subredditName.equals("popular") || subredditName.equals("all")) { intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3));
Intent intent = new Intent(this, MainActivity.class); intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(MainActivity.EXTRA_POST_TYPE, subredditName); intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(MainActivity.EXTRA_MESSSAGE_FULLNAME, messageFullname); startActivity(intent);
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)) { } else if (path.matches(USER_PATTERN)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class); Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, segments.get(1)); 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, PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, RandomBottomSheetFragment.RandomOptionSelectionCallback { ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, RandomBottomSheetFragment.RandomOptionSelectionCallback {
static final String EXTRA_POST_TYPE = "EPT";
static final String EXTRA_MESSSAGE_FULLNAME = "ENF"; static final String EXTRA_MESSSAGE_FULLNAME = "ENF";
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN"; 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(); loadUserData();
if (mAccessToken != null) { if (mAccessToken != null) {