[TIMOB-20262] Android: exception when borderColor is modified without setting first in the constructor
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 5.1.2 |
Fix Version/s | n/a |
Components | Android |
Labels | android, javascript |
Reporter | Ángel Flores |
Assignee | Unknown |
Created | 2016-01-19T09:30:09.000+0000 |
Updated | 2018-02-28T19:55:28.000+0000 |
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)
Hello, I was testing this issue. I find out the same problem when I tried to put a border color in the view of the selected table row when the row is clicked. I am testing the below code.
The below error occue
Environment
CLI 5.1.0 SDK 5.1.2.GA Android 5.1.0Expected result
View of the selected table row should show border color. Thanks.