Merge "Guard against the exceptions when launching a non-existing fragment" into sc-dev am: 1f4eb8fbcc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15142234 Change-Id: I9f806b71618c2447ddf9ad2322f9971ea3b1d89c
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
|
* 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) {
|
int titleResId, CharSequence title) {
|
||||||
Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
|
Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
|
||||||
if (validate && !isValidFragment(fragmentName)) {
|
if (validate && !isValidFragment(fragmentName)) {
|
||||||
@@ -582,6 +582,9 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
+ fragmentName);
|
+ fragmentName);
|
||||||
}
|
}
|
||||||
Fragment f = Utils.getTargetFragment(this, fragmentName, args);
|
Fragment f = Utils.getTargetFragment(this, fragmentName, args);
|
||||||
|
if (f == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
transaction.replace(R.id.main_content, f);
|
transaction.replace(R.id.main_content, f);
|
||||||
if (titleResId > 0) {
|
if (titleResId > 0) {
|
||||||
@@ -592,7 +595,6 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
transaction.commitAllowingStateLoss();
|
transaction.commitAllowingStateLoss();
|
||||||
getSupportFragmentManager().executePendingTransactions();
|
getSupportFragmentManager().executePendingTransactions();
|
||||||
Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
|
Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
|
||||||
return f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTilesList() {
|
private void updateTilesList() {
|
||||||
|
@@ -1158,13 +1158,17 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
== ProfileSelectFragment.ProfileType.PERSONAL : false;
|
== ProfileSelectFragment.ProfileType.PERSONAL : false;
|
||||||
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||||
== ProfileSelectFragment.ProfileType.WORK : false;
|
== ProfileSelectFragment.ProfileType.WORK : false;
|
||||||
if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
|
try {
|
||||||
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
|
||||||
&& !isWork && !isPersonal) {
|
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
||||||
f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
|
&& !isWork && !isPersonal) {
|
||||||
args);
|
f = Fragment.instantiate(activity,
|
||||||
} else {
|
ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), args);
|
||||||
f = Fragment.instantiate(activity, fragmentName, args);
|
} else {
|
||||||
|
f = Fragment.instantiate(activity, fragmentName, args);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Unable to get target fragment", e);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user