Skip to content
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

refactor(android): ScrollView now overrides toImage method #10529

Closed
wants to merge 1 commit into from

Conversation

ypbnv
Copy link
Contributor

@ypbnv ypbnv commented Dec 11, 2018

JIRA: https://jira.appcelerator.org/browse/TIMOB-26630

Description:
ScrollView now passes its inner layout to the UIHelper in order to allow conversion to image of its
whole content and not only the visible part.

Test case:
There is a good code snippet in the JIRA ticket.

ScrollView now passes its inner layout to the UIHelper in order to allow conversion to image of its
whole content and not only the visible part.
@build build added this to the 8.0.0 milestone Dec 11, 2018
@build build requested a review from a team December 11, 2018 16:22
@build
Copy link
Contributor

build commented Dec 11, 2018

Fails
🚫

😥 npm test failed. See below for details.

Messages
📖
> titanium-mobile@8.0.0 test /Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-10529
> grunt

Running "appcJs:src:lintOnly" (appcJs) task

Running "eslint:src" (eslint) task

/Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-10529/tests/Resources/ti.ui.ios.tabbedbar.addontest.js
31:38  warning  A space is required before ']'  array-bracket-spacing

✖ 1 problem (0 errors, 1 warning)
0 errors, 1 warning potentially fixable with the `--fix` option.


Running "checkFormat:ios" (checkFormat) task

Running "checkFormat:android" (checkFormat) task
Fatal error: Error: Formatting incorrect on "android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollView.java", proposed changes: <?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='36971' length='1'>&#10;	</replacement>
</replacements>
�
npm ERR! Test failed.  See above for more details.

Generated by 🚫 dangerJS

@Override
public KrollDict toImage() {
if (scrollView instanceof TiVerticalScrollView) {
return TiUIHelper.viewToImage(proxy.getProperties(), ((TiVerticalScrollView) scrollView).getLayout());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not introduce a very simple interface internally here that lists the methods common between the two implementations:

public interface TiScrollView {
  public TiScrollViewLayout getLayout();
}

It looks like this code isn't the only place where we're doing instanceof checks just to cast and ask for the exact same method signature. I imagine you could clean up the code nicely by introducing it and having the scrollView field be declared as a TiScrollView.

@jquick-axway
Copy link
Contributor

@ypbnv, I did a quick test on iOS and that platform captures the ScrollView container (including the border)... and not the whole inner offscreen contents. So, the captured image will be exactly what you see onscreen.

Android and iOS have parity here. Only discrepancy I saw was that Android does not capture the border. (Minor issue, but the customer isn't applying a border so we're fine for now.)

The ticket isn't a bug. I think the person is just asking our advise on how to capture the inner contents.

@ypbnv
Copy link
Contributor Author

ypbnv commented Dec 13, 2018

@sgtcoolguy Nice proposal. I will see to it.
@jquick-axway In case we have parity with iOS I am closing the PR. Thanks for checking it out!

@ypbnv ypbnv closed this Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants