[AC-889] NullPointerException on Ti.UI.Picker.showDatePickerDialog()
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Not Our Bug |
Resolution Date | 2015-09-29T03:55:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Jan van den Berg |
Assignee | Shak Hossain |
Created | 2015-03-09T14:18:08.000+0000 |
Updated | 2016-03-08T07:37:11.000+0000 |
Description
I get an NullPointerException When I open the date picker. It seems that it has something to do with the calendarView. So I've tried setting calendarViewShown to false. But that doesn't seem to do anything. It works on the simulator but not on the actual device. This is my code:
var datePicker = Ti.UI.createPicker(
{
type: Ti.UI.PICKER_TYPE_DATE
, minDate: args.minDate
, maxDate: args.maxDate
, value: value.toDate()
, calendarViewShown: false
} );
datePicker.setCalendarViewShown( false );
datePicker.showDatePickerDialog(
{
value: value.toDate()
, calendarViewShown: false
, callback: function( e )
{
if ( e.cancel )
{
// Cancel event, do nothing
}
else
{
if ( e.value )
{
$.setValue(
{
id: e.value
, value: moment( e.value ).format( "DD-MM-YYYY" )
} );
}
}
}
} );
This is the stacktrace:
[ERROR] TiApplication: (KrollRuntimeThread) [8780,14758] Sending event: exception on thread: KrollRuntimeThread msg:java.lang.NullPointerException; Titanium 3.5.1,2015/03/05 10:08,96875c9
[ERROR] TiApplication: java.lang.NullPointerException
[ERROR] TiApplication: at android.widget.CalendarView.onScroll(CalendarView.java:1216)
[ERROR] TiApplication: at android.widget.CalendarView.access$900(CalendarView.java:76)
[ERROR] TiApplication: at android.widget.CalendarView$2.onScroll(CalendarView.java:1077)
[ERROR] TiApplication: at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1463)
[ERROR] TiApplication: at android.widget.ListView.layoutChildren(ListView.java:1745)
[ERROR] TiApplication: at android.widget.AbsListView.onLayout(AbsListView.java:2149)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
[ERROR] TiApplication: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
[ERROR] TiApplication: at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
[ERROR] TiApplication: at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1877)
[ERROR] TiApplication: at android.widget.LinearLayout.onLayout(LinearLayout.java:1653)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
[ERROR] TiApplication: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
[ERROR] TiApplication: at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
[ERROR] TiApplication: at android.view.View.layout(View.java:15125)
[ERROR] TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4862)
[ERROR] TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
[ERROR] TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
Attachments
Apparently it's a known Android bug, to do with setting maxdate. The workaround provided by people is disabling the calendarview. But the designated titanium property is not doing anything for me. http://stackoverflow.com/questions/26225714/nullpointerexception-at-android-widget-calendarview-onscroll
Hi, I can't reproduce your problem in my device. Would you please try to create a new classic project with following codes, see if this cause problem in your test device.
Still seeing a calendar view.
I don't get the NullPointerException. But that's because the maxdate is more than x days separated from the min data. And that's an error in Android, not Titanium. But I my problem is that calendarViewShown: false doesn't work. I need this to work to bypass this Android bug. And I've tested your code on a classic project and still I see a calendar view. (See screenshot)
Hi , I tested the issue you reported. It looks like the feature "*Ti.UI.Picker.showDatePickerDialog()*" in Appcelerator Studio is working fine for me there is no NullPointerException . "*calendarViewShown: false*" is not working on android 5.1 , but it works fine for android 4.4.2 .This is not Appcelerator bug . This is a native Android issue . I tested this using the studio build: 4.1.1.201507141126 , TiSDK 4.1.0 GA and Appcelerator Command-Line Interface, version 4.1.2. Thanks