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

[TIMOB-19621]: tiImage() complete callback is not fired on Android #7280

Merged
merged 2 commits into from Nov 4, 2015

Conversation

sriks
Copy link
Contributor

@sriks sriks commented Oct 8, 2015

JIRA: https://jira.appcelerator.org/browse/TIMOB-19621
The java proxy method was not accepting params. So even though callback is provided in js, the result is retuned synchronously. Added the method params and handing accordingly.

if (TiApplication.isUIThread()) {
return handleToImage();

if (callback != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic of this if statement is flawed b/c it doesn't take into account TiApplication.isUIThread() clause. Also, you should return the TiBlob, not null even when there's a callback present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out. In case callback exists then the rendering should happen in a background thread but the method should return a 'non-null' blob immediately ? The documentation seems misleading about return value.

@hieupham007
Copy link
Contributor

Code reviewed. Please address comments

else {
// Create a non-null empty blob to return.
blob = TiBlob.blobFromImage(Bitmap.createBitmap(1, 1, Config.ARGB_8888));
Runnable renderRunnable = new Runnable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use TiMessenger.sendBlockingMainMessage here and pass an Object as argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling TiMessenger.sendBlockingMainMessage() is performing the msg synchronously while blocking on the main thread. This makes the method execution synchronous. But according to doc and iOS implementation - if a callback is passed the method is supposed to execute asynchronously. So Im using a Runnable to render and send the result through callback.

Am I missing anything here ?

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Nov 4, 2015
[TIMOB-19621]: tiImage() complete callback is not fired on Android
@hieupham007 hieupham007 merged commit 707baf6 into tidev:master Nov 4, 2015
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.

None yet

2 participants