Titanium JIRA Archive
Appcelerator Community (AC)

[AC-889] NullPointerException on Ti.UI.Picker.showDatePickerDialog()

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNot Our Bug
Resolution Date2015-09-29T03:55:44.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterJan van den Berg
AssigneeShak Hossain
Created2015-03-09T14:18:08.000+0000
Updated2016-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

FileDateSize
Screen Shot 2015-03-12 at 10.17.05 AM.png2015-03-12T09:21:54.000+000093828

Comments

  1. Jan van den Berg 2015-03-10

    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
  2. Shuo Liang 2015-03-11

    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.
       Ti.UI.backgroundColor = 'white';
       
       var picker = Ti.UI.createPicker({
       	type:Ti.UI.PICKER_TYPE_DATE,
         	minDate:new Date(2009,0,1),
         	maxDate:new Date(2014,11,31),
         	value:new Date(2014,3,12),
         	calendarViewShown: false
       });
       
       picker.showDatePickerDialog({
       	value: new Date(2010,8,1),
         	callback: function(e) {
         		if (e.cancel) {
             		Ti.API.info('User canceled dialog');
           	} else {
             		Ti.API.info('User selected date: ' + e.value);
           	}
        	}
       });
       
  3. Jan van den Berg 2015-03-12

    Still seeing a calendar view.
  4. Jan van den Berg 2015-03-12

    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)
  5. Harish Mridha 2015-08-26

    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

JSON Source