{ "id": "94781", "key": "TIMOB-9922", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-07-11T20:16:51.000+0000", "created": "2012-07-10T14:09:19.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "core", "parity" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-07-11T20:16:57.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h2. Expected result\r\n\r\nOnce an animation is _done_ the callback function would be invoked. In the following code, the label's text should not change until after the label has been moved off the screen.\r\n\r\nh2. Actual result\r\n\r\nThe callback is invoked immediately when the initial animation begins. The label changes immediately, then the label animates off the screen. With iOS and Mobile Web, the initial animation proceeds, and once done the label animates back onto the screen. On Android, the label never returns (probably due to TIMOB-6658).\r\n\r\nThe results are the same whether you use the inline-callback or listen for the 'complete' event and call a new animation.\r\n\r\nh2. Sample code\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor:'white'\r\n});\r\n\r\nvar titleLabel = Ti.UI.createLabel({\r\n\tleft:0, top:0,\r\n\twidth:'100%', height: '60dp',\r\n\ttext: 'Initial title',\r\n\tcolor: 'white',\r\n\tbackgroundColor:'#B32D00',\r\n\ttextAlign: 'center',\r\n\tfont: {\r\n\t\tfontWeight:'bold'\r\n\t}\r\n});\r\nwin.add(titleLabel);\r\n\r\nvar updateTitle = function(title){\r\n\ttitleLabel.animate({\r\n\t\tleft:-1000, top: 0,\r\n\t\tduration:2000\r\n\t}, function() {\r\n\t\t// THIS SHOULDN'T HAPPEN UNTIL THE LABEL HAS ANIMATED OFF THE SCREEN\r\n\t\ttitleLabel.animate({\r\n\t\t\tleft:0, top: 0,\r\n\t\t\tduration:2000\r\n\t\t}, function() {\r\n\t\t\t// AND THIS REALLY SHOULD NOT HAPPEN TILL AFTER BOTH ANIMATIONS ARE DONE\r\n\t\t\ttitleLabel.text=title;\r\n\t\t});\r\n\t});\r\n\ttitleLabel.text = title;\r\n};\r\n\r\nvar aOut = Ti.UI.createAnimation({\r\n\tleft: -1000, top: 0,\r\n\tduration: 2000\r\n});\r\nvar aBack = Ti.UI.createAnimation({\r\n\tleft: 0, top: 0,\r\n\tduration: 2000\r\n});\r\naOut.addEventListener('complete', function() {\r\n\t// THIS SHOULDN'T FIRE UNTIL THE LABEL HAS ANIMATED OFF THE SCREEN\r\n\ttitleLabel.animate(aBack);\r\n});\r\naBack.addEventListener('complete', function() {\r\n\t// AND THIS REALLY SHOULD NOT HAPPEN TILL AFTER BOTH ANIMATIONS ARE DONE\r\n\ttitleLabel.text = 'Click - Events';\r\n});\r\n\r\nvar updateTitle2 = function() {\r\n\ttitleLabel.animate(aOut);\r\n}\r\n\r\n// create a button that when clicked will animate the label\r\nvar btn = Ti.UI.createButton({\r\n\theight:'40dp',\r\n\twidth:'200dp',\r\n\tbottom: '60dp',\r\n\ttitle:'Click - Callbacks'\r\n});\r\nbtn.addEventListener('click', function(){\r\n\tupdateTitle('With Callbacks');\r\n});\r\nwin.add(btn);\r\n\r\n// create another button that when clicked will animate the label using the event listeners\r\nvar btn2 = Ti.UI.createButton({\r\n\theight:'40dp',\r\n\twidth:'200dp',\r\n\tbottom: '10dp',\r\n\ttitle:'Click - Event'\r\n});\r\nbtn2.addEventListener('click', function(){\r\n\tupdateTitle('With Events');\r\n});\r\nwin.add(btn2);\r\n\r\nwin.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: animation callback fired immediately (before animation has completed)", "creator": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "environment": "OS X Lion, TiSDK 2.1GA, also tested with 1.8.2 and 2.0.2GA\r\niOS simulator, Mobile Web: Chrome, Android device: Galaxy Nexus running Android 4.0.4", "comment": { "comments": [ { "id": "202720", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "TIMOB-6658 is still valid, but this one is apparently not. Labels don't change with corrected code sample.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2012-07-11T12:53:28.000+0000", "updated": "2012-07-11T12:53:28.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }