patzly / grocy-android

ERP beyond your fridge, now on your phone – An awesome companion app for grocy
https://patrickzedler.com/grocy/
GNU General Public License v3.0
899 stars 85 forks source link

[fixed] Crash on adding a date #351

Closed duylong closed 3 years ago

duylong commented 3 years ago

Hi,

I have a crash with 2.0.0-alpha02. I just added an expiration date in the purchase part.


--------- beginning of crash
02-12 14:33:27.115 24562 24562 E AndroidRuntime: FATAL EXCEPTION: main
02-12 14:33:27.115 24562 24562 E AndroidRuntime: Process: xyz.zedler.patrick.grocy, PID: 24562
02-12 14:33:27.115 24562 24562 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at java.lang.Double.parseDouble(Double.java:538)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.model.y0.j(SourceFile:8)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.l.k4.c0(SourceFile:2)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.fragment.PurchaseFragment.S1(SourceFile:10)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.fragment.PurchaseFragment.q1(SourceFile:1)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.d0.onDismiss(SourceFile:13)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at androidx.fragment.app.b.Y0(SourceFile:8)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at androidx.fragment.app.b.X0(SourceFile:1)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at com.google.android.material.bottomsheet.e.X0(SourceFile:6)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.c.onClick(SourceFile:1)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.view.View.performClick(View.java:7352)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.widget.TextView.performClick(TextView.java:14230)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at com.google.android.material.button.MaterialButton.performClick(SourceFile:2)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.view.View.performClickInternal(View.java:7318)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.view.View.access$3200(View.java:846)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.view.View$PerformClick.run(View.java:27800)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:873)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7050)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
02-12 14:33:27.115 24562 24562 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
02-12 14:33:29.915 25529 25529 E r.patrick.groc: Not starting debugger since process cannot load the jdwp agent.
02-12 14:33:38.902 25529 25529 E ViewRootImpl: sendUserActionEvent() returned.```

Galaxy S8
Android 9
gareth-ellis commented 3 years ago

I have the same isssue

dominiczedler commented 3 years ago

Mmh I cannot find the place in the code and I cannot reproduce it... Does this occur if you want to close the "date selection" dialogue? Or does it occur if you click on the date to open it? And do you have the Date Tracking feature enabled or disabled?

duylong commented 3 years ago

Yes, when I close the "date selection" dialogue ;) Date Tracking feature? What is this option?

patzly commented 3 years ago

@duylong In the server config file you can manually enable or disable certain features, date tracking is such a feature :) Grocy Android fetches the server config and hides the disabled functionality (not fully implemented yet).

dominiczedler commented 3 years ago

@duylong @gareth-ellis Can you please check if the crash still occurs in the new alpha03? Thanks!

gareth-ellis commented 3 years ago

Will do, i was trying to narrow down the cause - i recorded a video and then it worked fine - but will try alpha03 and report back

gareth-ellis commented 3 years ago

Seems to be working fine, just gone and scanned a load of items and set various dates (plus some never expires), and didnt crash once

dominiczedler commented 3 years ago

Great, thanks! If @duylong also experience no more crashes, we can close the issue.

duylong commented 3 years ago

I have only FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING to true ;)

I tested the new version, no more crashes but as soon as I validate the date selection, the product is automatically added...

dominiczedler commented 3 years ago

@duylong Thanks. This behavior is intended because you have the scan mode enabled (which you can see on the title bar color).