New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-20267] Android: fix slider track showing #8863
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
9f39721
to
e253a37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FR passed, was able to see the slider track beneath the transparent thumbImage.
Test Steps:
- Downloaded the SDK Build from this PR
- Created a new Titanium project
- Copied the the test case from description
- Added a transparent thumbimage and background
- Ran the application
- Was able to see the track bar under the transparent image
Test Environment
Appcelerator Command-Line Interface, version 6.2.2
Google Nexus 6P (7.1.1)
Nexus 6 (6.0)
Operating System Name: Mac OS X El Capitan
Operating System Version: 10.11.6
Node.js Version: 6.10.1
Xcode: 8.2
Appcelerator Studio: 4.9.0.201705251638
if (d.containsKey("thumbImage")) { | ||
updateThumb(seekBar, d); | ||
} | ||
|
||
if (d.containsKey(TiC.PROPERTY_SPLIT_TRACK)) { | ||
seekBar.setSplitTrack(TiConvert.toBoolean(d.get(TiC.PROPERTY_SPLIT_TRACK))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you guard this line to apply only for API 21 and above? It causes crashes on lower levels since it was added for Lollipop.
https://developer.android.com/reference/android/widget/AbsSeekBar.html#setSplitTrack(boolean)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch Yordan.
We also have to watch out in case the property value is not a boolean. So, the code should look something like this...
if (Build.VERSION.SDK_INT >= 21) {
ApiLevel21.setSplitTrack(this.seekBar, TiConvert.toBoolean([[value]], false));
}
private static class ApiLevel21
{
private ApiLevel21() {}
public void setSplitTrack(SeekBar seekBar, boolean enabled)
{
if (seekBar != null) {
seekBar.setSplitTrack(enabled);
}
}
}
The static inner class above avoids the opcode warning on the lower API levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guarding for API level.
Test Case:
Expect to see track to be visible beneath transparent thumbImage.
JIRA: https://jira.appcelerator.org/browse/TIMOB-20267