Other [SOLVED] B4XPreferencesDialog - B4J version bug?

LucaMs

Expert
Licensed 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
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?
 

stevel05

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

LucaMs

Expert
Licensed 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...!
 

LucaMs

Expert
Licensed 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).
 

LucaMs

Expert
Licensed 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...
 

Erel

Administrator
Staff member
Licensed User
You don't need to add a reference to jDateUtils because it is referenced by XUI Views.

I've ran the example and it works fine here.

Using B4XPreferencesDialog v1.65 and XUI Views v2.12.
 

LucaMs

Expert
Licensed 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
 

LucaMs

Expert
Licensed 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).
 

Erel

Administrator
Staff member
Licensed User
It is possible that the library was updated after the latest version of B4J was released.
 

LucaMs

Expert
Licensed User
"Strangely" :D now it works very well.

I have another question about it... opening a new thread ;)
 

LucaMs

Expert
Licensed 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.
 

Erel

Administrator
Staff member
Licensed 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.
 

LucaMs

Expert
Licensed 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:(
 

LucaMs

Expert
Licensed 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:

Erel

Administrator
Staff member
Licensed User
B4XPreferencesDialog is not designed for custom types.

A boolean type exists.
You can use the numeric range type for the volume. I might add a seek bar type in the future.
 
Top