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

Android: updateRow updates wrong/multiple rows when listening for and updating a child element of the row

    Details

    • Type: Bug
    • Status: Open
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      Titanium Studio, build: 3.2.3.201404181442 on OS X 10.9.3, Running Ti SDK 3.2.3 GA – issue visible in Android 2.3.x

      Description

      I have an app where I toggle a background image to flag or unflag a record by clicking a child element. I've recreated the problem with the code here:

      This doesn't work in Android 2.3.x, but works in iOS and Android 4.x

      (function() {
      	var win = Ti.UI.createWindow({
              backgroundColor: '#000',
              navBarHidden: true
          });
       
          var tableView = Ti.UI.createTableView();
            
          var data = [];
      		
          for (var i = 0; i < 10; ++i) {
              var tvr = Ti.UI.createTableViewRow({
              	backgroundColor:'white',
      			className:'tvRow',
      			height: 45
      		});
              var lbl = Ti.UI.createLabel({
      			text : ('Row ' + i),
      			color :'black',
      			font: { fontSize:'16sp' },
      			top : 5,
      			left : 5,
      			touchEnabled: true,
      			_class : 'myLabel',
      			_status:false
      		});
      		
      		tvr.add(lbl);
      		data.push(tvr);
          }
       
          tableView.setData(data);
           
          tableView.addEventListener('click', function(e) {
          	if(e.source._class == 'myLabel') {
          		Ti.API.info('myLabel clicked on row: ' + e.index);
          		if(e.source._status){
          			e.source.color = 'black';
          			e.source._status=false;
          		} else {
          			e.source.color='red';
          			e.source._status=true;
          		}
          		this.updateRow(e.index, e.row);
          	} else {
          		Ti.API.info('row: ' + e.index + ' clicked, but not flagged...');
          	}
          });
           
          win.add(tableView);
       
          win.open();
       
      })();
      

      The above code appears to work in every version of Android 4.x I've tried, and iOS. It just goes wonky in Android 2.3.x updating the wrong row or multiple rows when the label is clicked.

      Expected behavior is to click on a label, and it to toggle the clicked labels color depending on the labels "_status" value which is also toggled between true and false with each click of the label.

      To test it, create the app above and load it onto an Android 2.3.x device/emulator and then start clicking on the labels — clicking on the label should change the labels color, while clicking on a row outside of the label should do nothing. On android 2.3.x the wrong rows are updated and sometimes even multiple rows at the same time to seemingly random states.

      This seems similar to this https://jira.appcelerator.org/browse/TIMOB-9702, but still different as this has a focus on child elements and appears to be buggy regardless of whether there is a section header or not.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sliang Shuo Liang
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Source Code