Other [SOLVED] B4XPreferencesDialog - B4J version bug?

LucaMs

Expert
Licensed User
Longtime User
Error occurred on line: 89
java.lang.NullPointerException

The line is:
sb.Append($"Date and time: $DateTime{DateUtils.AddPeriod(birthday, time)}"$).Append(CRLF)

DateUtils is null. I added a reference to jDateUtils 1.05 but the exception is still raised.



[I would "like" to ask another question about B4APreferencesDialog but... I know, I should (must :D) open a new thread; also, I "need" to solve this bug, before]
 

stevel05

Expert
Licensed User
Longtime User
The syntax of your line as written is incorrect, this works for me:

B4X:
SB.Append($"Date and time: ${DateTime.Date(DateUtils.AddPeriod(Birthday,Time)) }"$).Append(CRLF)

Is the DateUtils module found when the lib is added?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
DateUtils is an internal library, do you have a version of the library in your additional libraries folder?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Hi, Steve ;)

The syntax of your line as written is incorrect, this works for me:
I have not checked the correctness of that line, as I trust its author (Erel :)); I simply set a break point and discovered that DateUtils was Null.

Is the DateUtils module found when the lib is added?
Not sure to understand what you mean; DateUtils is Null, so...!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
DateUtils is an internal library, do you have a version of the library in your additional libraries folder?
I added a reference to "a" version of jDateUtils (1.05) just because I got that error (the original project does not contain a reference to the library).

Do you think the integrated library is newer (I'm using the last version of B4J, of course)? However I try to remove not only the reference I added but also the library itself (which I suppose I added to the additional libraries).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
So... I probably misunderstood your statement (indeed, surely); I thought that now DateUtils (jDateUtils) was part of the Core library.

I found that I had jDateUtils both in the internal libraries directory and in the additional one. "Removed" (renamed) both, now the IDE warns me about the lack of it.

Let's see if restoring the internal library...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Using B4XPreferencesDialog v1.65 and XUI Views v2.12.
Only two minutes ago I had the flash of genius :D to check the requirements (the version of XUI Views required) but while I was doing it... your answer came, which confirms...

I have...

upload_2019-7-21_13-44-32.png



Thanks, Erel
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
But it's strange:

"Note that XUI Views is an internal library in B4J and B4A"

and I have the latest version of B4J.

Does this happen because in the past I installed b4j in the 32 bits folder (Programs (x86)) and "now", instead, in the one for 64 bits (Programs)?

(I keep the old installations).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I'm off topic but since I wrote those things here...

I conclude, just if by chance you had the curiosity, that I wanted to ask what, in your opinion, was the best design to manage the loading of the views, once the settings-preferences were read from disk.
Looking at the source, I realized that B4XPreferencesDialog deals with this, to which you pass the Map in this instruction:
B4X:
Wait For (prefdialog.ShowDialog(Options1, "OK", "CANCEL")) Complete (Result As Int)

So I'll have to look at the source of B4XPreferencesDialog.


Closed; after all the main question has been solved.


Thank you again.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Not sure if you find the answer in the source code or not, however you aren't expected to do anything special other than creating the template (with the json file) and then calling ShowDialog with the map file. You can call ShowDialog multiple times with different maps.
So I have to confess one thing: I was making my own version - not b4x - of a dialog for preferences and I wanted to find the best way (design) to associate the views of each item, so also the best way to load their values.

I like B4XPreferencesDialog, it is very convenient and very easy to use (along with the forms builder) but I wanted to customize some things.

I don't know which one I will opt for at the end; one of my main strengths is... my indecision :D:(
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Ok, even if I looked at it (B4XPreferencesDialog source code) quickly and at the same time I was doing other things, it seems to me that I understood that each item has its own specific type and in this way, thanks to this, the relative layout is loaded and the loading phase of the view values.

This is very... custom. It has its advantages but also its disadvantages: how can I insert various types of views of my choice into an item? For example, I would say a classic example, I could want in a single item a Checkbox to enable/disable the background music and also a SeekBar for the audio volume. To achieve this, I would have to change both B4XPreferencesDialog and the form builder sources.

However I like it!
 
Last edited:
Upvote 0
Top