Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24360] Android: Cant clear TableView anymore

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2019-08-05T17:13:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsdefect
ReporterCreative
AssigneeUnknown
Created2017-01-18T10:28:58.000+0000
Updated2019-08-05T17:13:37.000+0000

Description

Populate a Ti.UI.TableView with some rows, and try to remove them using:
$.myTableViewReference.setData([]);
// I also tried (which didnt work as well):
$.myTableViewReference.data = [];
I've attached a screenshot of the error I'm getting through Android Monitor (this doesnt show up in my Titanium console since the app just instantly dies). As stated, this is on Android only. I'm not having these issues with the same code on iOS. I was hoping to provide a testcase, but I cant reproduce it with a blank table like:
var x = Ti.UI.createTableView();
x.appendRow(Ti.UI.createTableViewRow());
x.data = [];
// The code above just works.

Attachments

FileDateSize
Schermafbeelding 2017-01-18 om 11.18.59.png2017-01-18T10:22:36.000+000058769

Comments

  1. Sharif AbuDarda 2017-01-18

    Hello, I am testing the below code in Android and it works as expected.
          <Alloy>
           <Window id="win" backgroundColor="white">
               <TableView id="table">
                       <TableViewRow title="Apple" backgroundColor="gray"/>
                       <TableViewRow title="Bananas" backgroundColor="gray"/>
                       <TableViewRow title="Carrots" backgroundColor="gray"/>
                       <TableViewRow title="Potatoes" backgroundColor="gray"/>
                       <TableViewRow title="Cod" backgroundColor="gray"/>
                       <TableViewRow title="Haddock" backgroundColor="gray"/>
               </TableView>
               <Button id="button" onClick="doClick" title="Hello"
               bottom="10" width="100" height="50" />
           </Window>
       </Alloy>
       
       function doClick(e) {
           Titanium.API.info("You clicked the button");
           $.table.data = [];
       };
       
       $.win.open();
       
    I can clear the table view with the blank date like this. Both $.table.setData([]); and $.table.data = [];. Thanks.
  2. Creative 2017-01-18

    hmm im positive it breaks in my (quite a bit bigger) situation. Perhaps try adding a clickhandler to the tableviewrows. I will try to debug the contents of the TableViewRow tomorrow, and see if any of that causes the issue. Sadly with this bug I cant deploy on SDK 6.0+. I will add to this bugreport soon.
  3. Sharif AbuDarda 2017-01-19

    Hello [~uzbbert], Did you checked? Get back to us.
  4. Creative 2017-01-19

    yes im on it
  5. Creative 2017-01-19

    i've managed to create a testcase:
       var x = Ti.UI.createTableView();
       var spacer = Ti.UI.createTableViewRow();
       
       x.add(spacer);
       x.addEventListener('postlayout',function() {
           spacer.height=10;
       });
       
       x.setData([]);
       
    This kills the application
  6. Sharif AbuDarda 2017-01-20

    Hello, I don't see the issue. with
       var win = Ti.UI.createWindow();
       win.open();
       
       var x = Ti.UI.createTableView();
       win.add(x);
       
       var spacer = Ti.UI.createTableViewRow();
       
       x.add(spacer);
       
       x.addEventListener('postlayout', function() {
       
           spacer.height = 10;
       
       });
       
       x.setData([]);
       
    I saw this error in console
       [ERROR] :  Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiUIView.registerForTouch()' on a null object reference
       
    But app opens fine. Thanks.
  7. Creative 2017-01-22

    What are you testing on? I ran the snippet on an Android Z3 Compact (D5803) running Android 6.0.1. As soon as this code is executed the app dies (it completely exits). Also the Error you're getting in the console, isnt that worth further investigation?
  8. Sharif AbuDarda 2017-01-23

    Hello, I am testing on Galaxy J7 Android 6.0.1.
  9. Creative 2017-01-25

    I've fixed this now in my situation, by simply re-assigning the spacer variable like TableView.data = [spacer] right after i've cleared the TableView. Still the sample code used to work on pre 6.0 SDK so I'm quite positive something has changed in the codebase that caused this. I expect the app to throw an error always, and that it should be impossible to completely kill the app due to a code error.
  10. Carlos Henrique Zinato 2017-07-07

    I was facing this problem on Android 6 with SDK 6.0.2.GA. This was working fine with 5.5.2. I was re-using some rows and updating then on the TableView. To fix it, I'm just destroying and creating the row again. But this still an issue I think.

JSON Source