Other [SOLVED] B4XPreferencesDialog - B4J version bug?

Discussion in 'B4J Questions' started by LucaMs, Jul 21, 2019.

  1. LucaMs

    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]
     
  2. stevel05

    stevel05 Expert Licensed User

    The syntax of your line as written is incorrect, this works for me:

    Code:
    SB.Append($"Date and time: ${DateTime.Date(DateUtils.AddPeriod(Birthday,Time)) }"$).Append(CRLF)
    Is the DateUtils module found when the lib is added?
     
  3. stevel05

    stevel05 Expert Licensed User

    DateUtils is an internal library, do you have a version of the library in your additional libraries folder?
     
  4. LucaMs

    LucaMs Expert Licensed User

    Hi, Steve ;)

    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.

    Not sure to understand what you mean; DateUtils is Null, so...!
     
  5. LucaMs

    LucaMs Expert Licensed User

    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).
     
  6. LucaMs

    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...
     
  7. LucaMs

    LucaMs Expert Licensed User

    Same exception.
     
  8. LucaMs

    LucaMs Expert Licensed User

    Have you tested the b4j version?
     
  9. Erel

    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 likes this.
  10. LucaMs

    LucaMs Expert Licensed User

    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
     
  11. LucaMs

    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).
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    It is possible that the library was updated after the latest version of B4J was released.
     
    LucaMs likes this.
  13. LucaMs

    LucaMs Expert Licensed User

    "Strangely" :D now it works very well.

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

    LucaMs Expert Licensed User

    No, I just have to study the source code (maybe... uhm... I'm not very convinced, I have to check).
     
  15. LucaMs

    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:
    Code:
    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.
     
  16. Erel

    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 likes this.
  17. LucaMs

    LucaMs Expert Licensed User

    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:(
     
  18. LucaMs

    LucaMs Expert Licensed User

    Furthermore, studying your source codes is good for your (my) health and brain :D
     
  19. LucaMs

    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: Jul 21, 2019
  20. Erel

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice