Merge "Simplify the transition logic." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-05-26 10:45:41 +00:00
committed by Android (Google) Code Review

View File

@@ -163,85 +163,23 @@ public class SettingsBaseActivity extends FragmentActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@Override
public void startActivity(Intent intent) {
if (!Utils.isPageTransitionEnabled(this)) {
super.startActivity(intent);
return;
}
final int transitionType = getTransitionType(intent);
if (transitionType == TransitionType.TRANSITION_SLIDE) {
super.startActivity(intent, null);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
} else if (transitionType == TransitionType.TRANSITION_NONE) {
super.startActivity(intent, null);
return;
} else if (transitionType == TransitionType.TRANSITION_FADE) {
super.startActivity(intent, null);
overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay);
return;
}
super.startActivity(intent, createActivityOptionsBundleForTransition(null));
}
@Override
public void startActivity(Intent intent, @androidx.annotation.Nullable Bundle options) {
final int transitionType = getTransitionType(intent);
if (!Utils.isPageTransitionEnabled(this) ||
transitionType == TransitionType.TRANSITION_NONE) {
super.startActivity(intent, options);
return;
}
if (transitionType == TransitionType.TRANSITION_SLIDE) {
super.startActivity(intent, options);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
}
super.startActivity(intent, createActivityOptionsBundleForTransition(options));
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
final int transitionType = getTransitionType(intent);
// startActivity() will eventually calls startActivityForResult() with requestCode -1.
// Adding this condition to avoid multiple calls.
if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST
|| transitionType == TransitionType.TRANSITION_NONE) {
super.startActivityForResult(intent, requestCode);
return;
}
if (transitionType == TransitionType.TRANSITION_SLIDE) {
super.startActivityForResult(intent, requestCode, null);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
}
super.startActivityForResult(intent, requestCode,
createActivityOptionsBundleForTransition(null));
}
@Override @Override
public void startActivityForResult(Intent intent, int requestCode, public void startActivityForResult(Intent intent, int requestCode,
@androidx.annotation.Nullable Bundle options) { @androidx.annotation.Nullable Bundle options) {
final int transitionType = getTransitionType(intent); final int transitionType = getTransitionType(intent);
if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST if (Utils.isPageTransitionEnabled(this) &&
|| transitionType == TransitionType.TRANSITION_NONE) { transitionType == TransitionType.TRANSITION_SHARED_AXIS) {
super.startActivityForResult(intent, requestCode, options); super.startActivityForResult(intent, requestCode,
createActivityOptionsBundleForTransition(options));
return; return;
} }
super.startActivityForResult(intent, requestCode, options);
if (transitionType == TransitionType.TRANSITION_SLIDE) { if (transitionType == TransitionType.TRANSITION_SLIDE) {
super.startActivityForResult(intent, requestCode, options);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return; } else if (transitionType == TransitionType.TRANSITION_FADE) {
overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay);
} }
super.startActivityForResult(intent, requestCode,
createActivityOptionsBundleForTransition(options));
} }
@Override @Override