So in trying to use the Slide
Activity transition but with a different gravity, the app crashes on using Gravity.START
, using this:
getWindow().setExitTransition(new Slide(Gravity.START));
and I get this error:
IllegalArgumentException: Invalid slide direction
But yet if you look in the source code, that specific constructor above calls setSlideEdge()
in which case that method goes through a switch statement to set the Gravity you specified earlier:
switch (slideEdge) {
case Gravity.LEFT:
mSlideCalculator = sCalculateLeft;
break;
case Gravity.TOP:
mSlideCalculator = sCalculateTop;
break;
case Gravity.RIGHT:
mSlideCalculator = sCalculateRight;
break;
case Gravity.BOTTOM:
mSlideCalculator = sCalculateBottom;
break;
case Gravity.START:
mSlideCalculator = sCalculateStart;
break;
case Gravity.END:
mSlideCalculator = sCalculateEnd;
break;
default:
throw new IllegalArgumentException("Invalid slide direction");
}
Gravity.LEFT
works just fine, but because I want RTL support, it only makes sense to instead use Gravity.START
. I'm confused as to why the default case is executed in this switch statement, and the only explanation for it is it's a bug.
I'd report it to Google but they don't have public ways of reporting API bugs like this, and in this case the bug isn't exactly obvious to fix. So, PSA to anyone that wants to use the Slide animation with a Gravity of START
.