florent37 / SingleDateAndTimePicker

You can now select a date and a time with only one widget !
Apache License 2.0
1.02k stars 333 forks source link

Getting NullPointerException on doubleDateAndTimePickerDailog #273

Closed ziyadrahman closed 4 years ago

ziyadrahman commented 4 years ago
java.lang.NullPointerException
    at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:422)
    at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30)
    at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:725)
    at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:743)
momadthenomad commented 4 years ago

Probably has to do with doing: .setTimeZone(TimeZone.getDefault()) before you call any of the set date/time functions. Per issue #271

florent37 commented 4 years ago

I fixed this in the 2.2.4, can you try ?

https://github.com/florent37/SingleDateAndTimePicker/commit/09c61b42d688bf79537d30476d966f3faf1b5eb4

momadthenomad commented 4 years ago

Yep, it is fixed. Thanks!

ziyadrahman commented 4 years ago

sorry to say i getting same error

ziyadrahman commented 4 years ago
` java.lang.NullPointerException
        at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:422)
        at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30)
        at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:725)
        at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:743)
        at com.example.android.saffronfromzr.OrderActivity.openBottonCalender(OrderActivity.java:498)
        at com.example.android.saffronfromzr.OrderActivity$1.onClick(OrderActivity.java:155)
        at android.view.View.performClick(View.java:4508)
        at android.view.View$PerformClick.run(View.java:18675)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5584)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)

`Code

  new DoubleDateAndTimePickerDialog.Builder(this)

                        .title("SELECT DATES")
                        .tab0Text("ORDER DATE")
                        .tab1Text("DELIVERY DATE")
                        .backgroundColor(getResources().getColor(R.color.white))
                        .bottomSheet()
                        .listener(new DoubleDateAndTimePickerDialog.Listener() {
                            @Override
                            public void onDateSelected(List<Date> dates) {
                                orderDateString=dateToString(dates.get(0));
                                orderDateText.setText(orderDateString);
                                deliveryDateString=dateToString(dates.get(1));
                                setPickDelDateTextViewVisibility(GONE);
                                delDateText.setText(deliveryDateString);
                                if (validation()) {
                                    setHandWorkLayoutVisibility(VISIBILE);
                                    setAddOrderTextViewVisibility(INVISBILE);

                                }
                                else
                                {
                                    setHandWorkLayoutVisibility(GONE);
                                    setAddOrderTextViewVisibility(VISIBILE);

                                }

                            }
                        }).display();
momadthenomad commented 4 years ago

Post a GitHub repo with the minimal code to show the error. Or a gist with an activity with minimal code.

On Sun, May 10, 2020 at 3:31 PM ziyadrahman notifications@github.com wrote:

` java.lang.NullPointerException at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:422) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:725) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:743) at com.example.android.saffronfromzr.OrderActivity.openBottonCalender(OrderActivity.java:498) at com.example.android.saffronfromzr.OrderActivity$1.onClick(OrderActivity.java:155) at android.view.View.performClick(View.java:4508) at android.view.View$PerformClick.run(View.java:18675) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5584) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)

`Code

new DoubleDateAndTimePickerDialog.Builder(this)

                    .title("SELECT DATES")
                    .tab0Text("ORDER DATE")
                    .tab1Text("DELIVERY DATE")
                    .backgroundColor(getResources().getColor(R.color.white))
                    .bottomSheet()
                    .listener(new DoubleDateAndTimePickerDialog.Listener() {
                        @Override
                        public void onDateSelected(List<Date> dates) {
                            orderDateString=dateToString(dates.get(0));
                            orderDateText.setText(orderDateString);
                            deliveryDateString=dateToString(dates.get(1));
                            setPickDelDateTextViewVisibility(GONE);
                            delDateText.setText(deliveryDateString);
                            if (validation()) {
                                setHandWorkLayoutVisibility(VISIBILE);
                                setAddOrderTextViewVisibility(INVISBILE);

                            }
                            else
                            {
                                setHandWorkLayoutVisibility(GONE);
                                setAddOrderTextViewVisibility(VISIBILE);

                            }

                        }
                    }).display();

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/SingleDateAndTimePicker/issues/273#issuecomment-626321161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQKFTESHZMAY2WEXJELOCLRQ2ND3ANCNFSM4MXIG3LQ .

abalta commented 4 years ago

Same issue @momadthenomad @florent37

Crash Log: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker.setTimeZone(java.util.TimeZone)' on a null object reference

 private fun showDateAndTimePicker(onSelectedStart: (String) -> Unit, onSelectedEnd: (String) -> Unit) {
        DoubleDateAndTimePickerDialog.Builder(this)
                .bottomSheet()
                .bottomSheetHeight(resources.getDimensionPixelSize(R.dimen._306sdp))
                .curved()
                .title(getString(R.string.hint_select_date_time))
                .tab0Text(getString(R.string.hint_start_date))
                .tab1Text(getString(R.string.hint_end_date))
                .setTimeZone(TimeZone.getDefault())
                .listener {
                    onSelectedStart(it[0].formatToViewTime())
                    onSelectedEnd(it[1].formatToViewTime())
                }
                .display()
    }
mhdfazil commented 4 years ago

Same issue @momadthenomad @florent37 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker.setTimeZone(java.util.TimeZone)' on a null object reference at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:427) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:736) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:755)

momadthenomad commented 4 years ago

What version are you using?

On Tue, Jul 14, 2020 at 8:58 PM Fazil notifications@github.com wrote:

Same issue @momadthenomad https://github.com/momadthenomad @florent37 https://github.com/florent37

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker.setTimeZone(java.util.TimeZone)' on a null object reference at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:427) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:736) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:755)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/florent37/SingleDateAndTimePicker/issues/273#issuecomment-658325425, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQKFTF4EWUVOHNE5BR62U3R3SMDXANCNFSM4MXIG3LQ .

mhdfazil commented 4 years ago

What version are you using? On Tue, Jul 14, 2020 at 8:58 PM Fazil @.***> wrote: Same issue @momadthenomad https://github.com/momadthenomad @florent37 https://github.com/florent37 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker.setTimeZone(java.util.TimeZone)' on a null object reference at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.setTimeZone(DoubleDateAndTimePickerDialog.java:427) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog.access$700(DoubleDateAndTimePickerDialog.java:30) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.build(DoubleDateAndTimePickerDialog.java:736) at com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog$Builder.display(DoubleDateAndTimePickerDialog.java:755) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#273 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQKFTF4EWUVOHNE5BR62U3R3SMDXANCNFSM4MXIG3LQ .

I am using latest version 2.2.6