Skip to content

fix(android): cast compressionLevel to int in switch statement#342

Open
FerRiv3ra wants to merge 1 commit intomockingbot:masterfrom
FerRiv3ra:fix/switch-double-compressionlevel
Open

fix(android): cast compressionLevel to int in switch statement#342
FerRiv3ra wants to merge 1 commit intomockingbot:masterfrom
FerRiv3ra:fix/switch-double-compressionlevel

Conversation

@FerRiv3ra
Copy link
Copy Markdown

Java does not support switch on double values — only int, char, byte, short, String, and enums are valid selector types.

getCompressionLevel(double compressionLevel) uses switch (compressionLevel) which fails to compile with newer JDK/AGP versions:

error: constant label of type int is not compatible with switch selector type double

The fix casts to int before the switch. This is safe since all valid values (-1, 09) are whole numbers passed from JS.

Fixes #341

Java does not support switch on double values. Casting to int is safe
since all valid compression level values (-1, 0-9) are whole numbers
passed from JS.

Fixes mockingbot#341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(android): switch on double fails to compile — cast to int

1 participant