Guard against the exceptions when launching a non-existing fragment
Test: robotest Bug: 190371550 Change-Id: I2bb7d4bdb23756634526db7e272563a1587c9640
This commit is contained in:
@@ -574,7 +574,7 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
/**
|
||||
* Switch to a specific Fragment with taking care of validation, Title and BackStack
|
||||
*/
|
||||
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
|
||||
private void switchToFragment(String fragmentName, Bundle args, boolean validate,
|
||||
int titleResId, CharSequence title) {
|
||||
Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
|
||||
if (validate && !isValidFragment(fragmentName)) {
|
||||
@@ -582,6 +582,9 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
+ fragmentName);
|
||||
}
|
||||
Fragment f = Utils.getTargetFragment(this, fragmentName, args);
|
||||
if (f == null) {
|
||||
return;
|
||||
}
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.main_content, f);
|
||||
if (titleResId > 0) {
|
||||
@@ -592,7 +595,6 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
transaction.commitAllowingStateLoss();
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
|
||||
return f;
|
||||
}
|
||||
|
||||
private void updateTilesList() {
|
||||
|
||||
Reference in New Issue
Block a user