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

Android: exception when borderColor is modified without setting first in the constructor

    Details

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

      Windows 10 + Titanium SDK 5.1.2GA

      Description

      I want to mark a row of a table as selected using a border. Given that the border does not work at all if it is set in the tableViewRow, I tried it using an inner view.

      If I try to modify the color of the view border without setting first in the constructor, an exception is thrown.

      var table = Ti.UI.createTableView({id:"table", top:10, width:Ti.UI.FILL, height:Ti.UI.SIZE, backgroundColor: Config.BACKGROUND_COLOR_LIST, scrollable:true, separatorColor:"white", title: {font:{fontWeight:'bold'}}});
      	var row = Ti.UI.createTableViewRow({id: Math.random(), width:Ti.UI.FILL, height:Ti.UI.SIZE, layout: "horizontal", backgroundFocusedColor: Config.MAIN_COLOR, chosen:false});
                  var borderView=Ti.UI.createView({width:Ti.UI.SIZE, height:Ti.UI.SIZE, layout: "horizontal", /*borderColor:Config.BUTTON_COLOR, */borderWidth:0});
                      var logo = Ti.UI.createImageView({width:"20%", height:Ti.UI.SIZE, image: '/appicon.png', defaultImage: '/appicon.png'});
                      var content= Ti.UI.createView({width:"80%", height:Ti.UI.SIZE});
      				...
      				...
      				...
      row.addEventListener("click", rowClickEvent(row.id));
       
       
      function rowClickEvent(rowId)
      {
          return function()
          {
              var dataRows = table.data[0].rows;
              
              for(i=0;i<dataRows.length;i++)
              {
                  var item = dataRows[i];
                  var borderView = item.children[0];
                  
                  if(rowId == item.id)
                  {
                      item.chosen= !item.chosen;
                      
                      button.disabled = !item.chosen;
                      if(item.chosen)
                      {
                          Ti.API.info("Selecting the row...");
                          borderView.borderColor=Config.BUTTON_COLOR;//<-----it throws an exception
                          borderView.borderWidth = '5dp';
                      }
                      else
                      {
                          Ti.API.info("Unselecting the row...");
                          borderView.borderColor=Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception
                          borderView.borderWidth = 0;
                      }
                  }
                  else if(item.chosen && (rowId != item.id))//avoid the blink
                  {
                      Ti.API.info("Unselecting the row...");
                      borderView.borderColor = Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception
                      borderView.borderWidth = 0;
                      item.chosen=false;
                  }
              }
          };
      }
       
      [ERROR] :  TiApplication: (main) [12903,12903] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference; Titanium 4.0.0,2015/05/18 15:42,9239ff9
      [ERROR] :  TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1269)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:842)
      [ERROR] :  TiApplication: 	at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
      [ERROR] :  TiApplication: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1083)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
      [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:98)
      [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:135)
      [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5538)
      [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:372)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
      
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              angelf Ángel Flores
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Source Code