Inline Java

Discussion in 'Chit Chat' started by Erel, Jan 29, 2015.

  1. Erel

    Erel Administrator Staff Member Licensed User

  2. wonder

    wonder Expert Licensed User

    Erel, that's fantastic!!! :)
     
  3. thedesolatesoul

    thedesolatesoul Expert Licensed User

    So it handles activity/service/class events as well!?
     
    Peter Simpson and NJDude like this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    (What do you mean with class events?)

    It works with hooks that I add to the template code.
     
  5. susu

    susu Well-Known Member Licensed User

    Will it support external library (.jar file) ? If yes, can I compile it to B4A wrapper?
     
  6. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I guess Java should be the next language I learn. I mean that in the broadest of terms, attempt to understand might have been more precise.
     
    Peter Simpson and inakigarm like this.
  7. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Thanks for this.

    I guess a B4A class is also coming from a Java class, which has events like onCreate etc? To be honest, there is no point in hooking into class events, but I just wanted to be generic.

    I may be complicating things but there are a couple of scenarios I think about:
    - There is a possibility of running setTheme in onCreate BEFORE calling super.onCreate and setContentView to change the theme at runtime
    - There is a possibility of running onPreparedOptionsMenu AFTER the template code to decontruct and reconstruct the menu
    - There is a possiblity of completely overriding events like onPrepareOptions (not a good option, but it means you dont have to deconstruct things)
    I know this is for the savy, the slick and the spurious, but hey, you are the sublime!

    Can you elaborate on this?
     
    NJDude likes this.
  8. thedesolatesoul

    thedesolatesoul Expert Licensed User

    The answer to this is yes.
    Add AdditionalJar to the attributes.
    You will have to do imports in the inline java. And call methods.
    If you write your code in a class you can compile to B4A lib.
    But again, it also depends on the complexity of the lib. It will be less typing than Java Object but I think it will offer the same features.
     
    Last edited: Jan 29, 2015
    Peter Simpson, NJDude and susu like this.
  9. KMatle

    KMatle Expert Licensed User

    My thoughts: It IS very helpful to many developers but hopefully there is not too much Java coding & questions here in the forum the next months or new functions which will be coded only in Java. The main reason for me using B4A is not to use Java. We will see.
     
    Peter Simpson likes this.
  10. Erel

    Erel Administrator Staff Member Licensed User

    Yes. This is exactly the example in the first post.
    You will be able to prevent the standard onPreparedOptionsMenu from running at all and run your code instead (or run both where your code runs first).
     
  11. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Not really understanding all what is said but seems to be a great step for B4A
     
    DonManfred and Beja like this.
  12. thedesolatesoul

    thedesolatesoul Expert Licensed User

    That is very impressive then.
    I just realized that _onCreate runs first then Activity_Create and then Test.
    Its a little bit insane and dizzying!
     
    Inman, Erel and NJDude like this.
  13. coslad

    coslad Well-Known Member Licensed User

    Thanks Erel
     
  14. Troberg

    Troberg Well-Known Member Licensed User

    Why "#if Java"? Shouldn't it be something like "#begin Java"? It's not really a test, it's an indication that what is to follow is Java, not B4A.

    Or am I just stupid and missing the obvious?
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    You can say the same thing about #If B4A or #IF B4J.

    The inline Java feature is based on the same conditional compilation system.
     
    Peter Simpson and lemonisdead like this.
  16. corwin42

    corwin42 Expert Licensed User

    This will add a new level of possibilities. Many, many thanks.
     
  17. Troberg

    Troberg Well-Known Member Licensed User

    But, will there ever be a situation when #If Java is false? And, if there is, wouldn't that kind of break the useability of this feature pretty hard?

    I can easily see why #If B4A or #If B4J could be false, so there it makes sense, but if we are in a situation where Java is not available, wouldn't that break everything?

    Edit: Nevermind. After reading the post on inline ObjectiveC in B4i, I get it. I forgot that we don't always compile to Java...
     
    Last edited: Jan 30, 2015
  18. Beja

    Beja Expert Licensed User

    Thank you Erel so much, you succeeded in dragging me to java that I always didn't like.. now I can tweet java codes until I learn the language and one day can write entire app with java.
     
  19. moster67

    moster67 Expert Licensed User

    Is this ironical?

    I think the inline feature will be a great feature. For instance you can implement code-snippets in JAVA directly in your B4a-code without the hassle of writing a wrapper and loosing time. I think the aim of this feature is just to make B4a even more flexible than it is today. If you want to use it, that is up to you.
     
  20. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Knowing Beja, it is absolutely not ironical. He only wanted to thank Erel for letting us use Java easily along with B4A :)
     
    Peter Simpson and Beja like this.
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