Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15634] Android: convertPointToView returns null for Views inside of a ListView

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-06-06T13:09:30.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam
ReporterMostafizur Rahman
AssigneeIngo Muschenetz
Created2013-09-15T22:30:41.000+0000
Updated2017-03-21T21:56:30.000+0000

Description

Problem Description

convertPointToView returns wrong result in android when views inside of a ListView. This function working good in IOS but not working in Android.

Test Environments

OS: MAC OX X 10.8.5 Alloy 1.2.2 Ti SDK: 3.1.2 GA, 3.1.3 GA Ti CLI: 3.2.0 Simulator 7.0 Android Emulator with Android SDK 2.3.3 Android Device

Test Code

index.xml
<Alloy>
	<Tab id="scoresTab" title="Scores">
            <Window id="win" title="Scores" class="container">
	        <ListView id="listView" defaultItemTemplate="headerTemplate" allowsSelection="true">
	            <Templates>
	                <ItemTemplate id="headerTemplate" name="header">
	                    <Button platform="android" bindId="scale" id="scaleHeadId" onClick="doClick"></Button>
	                </ItemTemplate>
	            </Templates>

	            <ListSection id="headerSection">
	            </ListSection>
	        </ListView>
            </Window>
	</Tab>
</Alloy>

index.js

function doClick(e)
{
 	if (isAndroid)
	{
		var pt = {x: e.x, y: e.y};
		// The next line seems to return null no matter what destination view I choose $.win, $.listView, $.scoresTab
		pt = e.source.convertPointToView(pt, $.win);
		if (pt == null)
			Titanium.API.info('pt is null');
                else
			Titanium.API.info('working');
	}
}

Step to reproduce

Create new Alloy Project

Update index.xml and index.js file

Run on Android Emulator/Device

Click on listView

Check console its print "pt is null"

Expected Result

Console will print "working"

Comments

  1. Young 2014-01-27

    Hi Ingo, This issue have been reported for over 6 months now. Any chance of fixing it soon? Thanks.
  2. Sunila 2014-03-27

    I am not able to reproduce the issue. Here is the test case I tried
               var tabGroup = Titanium.UI.createTabGroup();
       
       	var win = Titanium.UI.createWindow({
       		backgroundColor : "#fff"
       	});
       
       	var win = Ti.UI.createWindow({backgroundColor: 'white'});
       	
       	var tab1 = Titanium.UI.createTab({
       		title : 'Scores',
       		window : win
       	});
       	
       	
       
       	// Create a custom template that displays an image on the left, 
       	// then a title next to it with a subtitle below it.
       	var myTemplate = {
       	    childTemplates: [
       	        {                            // Image justified left
       	            type: 'Ti.UI.Button', // Use button
       	            bindId: 'info',           // Maps to a custom pic property of the item data
       	            events: {
       	                // Bind event callbacks only to the subcomponent
       	                click: doClick
       	            },
       	        }
       	    ]
       	};
       
       	var listView = Ti.UI.createListView({
       	    // Maps myTemplate dictionary to 'template' string
       	    templates: { 'template': myTemplate },
       	    // Use 'template', that is, the myTemplate dict created earlier
       	    // for all items as long as the template property is not defined for an item.
       	    defaultItemTemplate: 'template'
       	});
       	var sections = [];
       
       	var fruitSection = Ti.UI.createListSection({ headerTitle: 'Test'});
       	var fruitDataSet = [
       	    { info: {title: 'Apple'}},
       	    { info: {title: 'Banana'}}
       	];
       	fruitSection.setItems(fruitDataSet);
       	sections.push(fruitSection);
       	
       	function doClick(e)
       	{
       		var pt = {x: e.x, y: e.y};
       		// The next line seems to return null no matter what destination view I choose $.win, $.listView, $.scoresTab
       		pt = e.source.convertPointToView(pt, win);
       		if (pt == null)
       			Titanium.API.info('pt is null');
               else
       			Titanium.API.info('working');
       	}
       
       
       	listView.setSections(sections);
       	win.add(listView);
       	tabGroup.addTab(tab1);
       	tabGroup.open();
       
  3. Young 2014-03-27

    Hi Sunila, Did you run with the test code that was provided by Ingo (above)?
  4. Sunila 2014-03-30

    I have try to run the Alloy test code in the bug but it doesn't launch the app properly.
  5. Young 2014-03-30

    The test code was from Ingo, you may want to check with Ingo?
  6. Young 2014-04-06

    Sunila & Ingo, what's going on guys? It's outstanding for over *9 months* since we first reported it and still unresolved!!
  7. Lokesh Choudhary 2014-06-04

    Issue is not reproducible with the test code provided by [~sunila] . convertPointToView does not return "null". Environment: Appc Studio : 3.3.0.201405271647 Ti SDK : 3.3.0.v20140603152512 Mac OSX : 10.8.5 Alloy : 1.4.0-beta CLI - 3.3.0-beta2 Code Processor: 1.1.1 Nexus 5 - android 4.4.2
  8. Ingo Muschenetz 2014-06-06

    We have tried to reproduce this issue three separate times to no avail. If someone can provide a test case that demonstrates the problem, we'd be happy to reopen it.
  9. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source