Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-9054

Android: Loosing the value of the source in an event

    Details

      Description

      Problem Description

      When processing custom events, the source of the event is not passing complete. This used to work in SDK 1.7.6.

      Actual Results

      The source of the event is not complete, so it's failing.

      Expected results

      The events working as before

      Test Case

      1. Create a new mobile Project
      2. PAste this:

      var fundListSize,fundCheckboxArray=[],fundsToPlotCount,grey=false,lightBlue=false,clickEvent=false,fundsSitemanagerMsg=null;
      var win = createHistoricalFundGraphFundsWindow();
      win.orientationModes = [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT];
      win.open()
       
      /*
       * Function to display the available funds that can be selected to display on the graph
       */
      function createHistoricalFundGraphFundsWindow() {
      	/* Declaring the variables*/
      	var iOSTopTitle, planText, navTitleText, menuTitle, winLeftNavButton, winRightNavButton, winBackButtonTitle, winBackButtonTitleImage, winTabBarHidden, subHeader, tableViewDS, genericTableView, win;
      	fundsSitemanagerMsg = ''//_response.historicalFundGraphFundMessage;
      	fundsToPlotCount = 3;
       
          /* reset fundlistsize*/
      	fundListSize = 0;
       
      	tableViewDS = createHistoricalFundGraphFundsTableViewDS();
      	genericTableView = Titanium.UI.createTableView({
      		separatorColor:'#e7e7e7',
      		data : tableViewDS,
      		backgroundColor :'#e7e7e7'
      	});
          
      	genericTableView.top = 0;
      	genericTableView.backgroundColor = '#e7e7e7';
      	tableViewDS = null;
                       
      	var menuWindow = Titanium.UI.createWindow({
      		barColor : '#929292',
      		backgroundColor : '#E7E7E7'
      	});
          
      	menuWindow.add(genericTableView);
      	return menuWindow;
      };
       
      /*
       * Function to create the data source to be added to the tableview that displays the funds
       */
      function createHistoricalFundGraphFundsTableViewDS() {
      	var responseLength=2;
      	var datasource=[];
      	var datasourceChecked=[];
      	var fundRow,boxChecked;
      	boxChecked=false;
      	fundCheckboxArray.push(createHFGCheckBox('','xyz',boxChecked));
      	fundCheckboxArray.push(createHFGCheckBox('','abc',boxChecked));
      	fundRow=createHFGRowLndScpe({
      		fFundName: 'xyz',
      		sSwitch: fundCheckboxArray[0]
      	});
      	var fundRow1=createHFGRowLndScpe({
      		fFundName: 'abc',
      		sSwitch: fundCheckboxArray[1]
      	});
       
      	datasource.push(fundRow);
      	datasource.push(fundRow1);
      	fundListSize = 2;
      	return datasource;
      };
      /*
       * function to create checkbox ( a button masked as checkbox, not a switch ) for each row
       */
      function createHFGCheckBox(_fundNum,_fundName,_checked) {
       
      	var checkbox = Ti.UI.createButton({
      		title:'',
      		right:'5%',
      		width:28,
      		height:28,
      		font: {
      			fontSize: 14,
      			fontWeight: 'bold'
      		},
      		value:_checked,
      		fundNum:_fundNum,
      		fundName:_fundName,
      		checkColor:'none'
      	});
       
      	/* attach on/off actions */
      	checkbox.on = function() {
      		this.value = true;
      		this.title='ON';
      	};
      	checkbox.off = function() {
      		this.value = false;
      		this.title='OFF';
      	};
       
      	/* fire action to check or uncheck based on _checked bool param */
      	if (_checked) {
      		checkbox.on();
      	} else {
      		checkbox.off();
      	}
       
      	checkbox.addEventListener('updateCheckBox', function(e) {
      		alert(e)
      		/* can always turn checkboxes off */
      		if(e.source.value == true)
      		{
      			checkbox.off();
      		}
      		else
      		{
      			checkbox.on();
      		}
      	});
      	return checkbox;
      };
           
      /*
       * Function to create  row for fund label
       */
      function createHFGRowLndScpe(_fundBalData) {
      	if( typeof _fundBalData !== 'undefined' && _fundBalData !== null) {
      		var _fundName = _fundBalData.fFundName;
      		var row = Titanium.UI.createTableViewRow({
      			backgroundColor : '#FFFFFF',
      			selectedBackgroundColor : '#FFFFFF',
      			selectionStyle : 'NONE'
      		});
      		var checkBoxView = Ti.UI.createView({
      			right : 0,
      			height : 30,
      			width : '30%',
      		})
      		row.addEventListener('click', function(e) {
      			var id = e.index;
      			Ti.API.info('Row got click Source: '+e.source+' Row Index:'+e.index);
      			if( typeof id !== 'undefined' && id !== null) {
      				fundCheckboxArray[id].fireEvent('updateCheckBox');
          		}
      		});
      		var fundNameLabel = Titanium.UI.createLabel({
      			left : '5%',
      			width : '65%',
      			top : 15,
      			bottom : 15,
      			height : 'auto',
      			color : '#363636',
      			text : _fundName,
      			font : {
      				fontSize : 15,
      				fontFamily : 'Helvetica Neue',
      				fontWeight : 'bold'
      			},
      		});
      		row.add(fundNameLabel);
      		_fundName = null;
      		checkBoxView.add(_fundBalData.sSwitch);
      		row.add(checkBoxView);
      		return row;
      	}
      };
      

      3. Test in 1.7.6, working fine.
      4. Now test in 2.1CI, it will fail.

      Extra info

      The interesting part is

      checkbox.addEventListener('updateCheckBox', function(e) {
      		alert(e)
      		/* can always turn checkboxes off */
      		if(e.source.value == true)
      		{
      			checkbox.off();
      		}
      		else
      		{
      			checkbox.on();
      		}
      	});
      

        Attachments

          Activity

            People

            • Assignee:
              joshroesslein Josh Roesslein
              Reporter:
              mpmiranda Mauro Parra-Miranda
            • Watchers:
              0 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-13293
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code