B4A Library [B4X] [XUI] Animated Counter

Discussion in 'Additional libraries, classes and official updates' started by Erel, Mar 11, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    [​IMG]

    Class supported by B4i, B4A and B4J.

    The animation is very smooth (smoother than in the above animated gif).

    The class is available inside the attached B4J project.
    And depends on: XUI, JavaObject libraries.
     

    Attached Files:

    Last edited: Oct 4, 2018
  2. Jeffrey Cameron

    Jeffrey Cameron Active Member Licensed User

    A quick question... I've noticed that for projects such as this (and, for example, the "wheel" class example) you have chosen to include a PNG file that is a simple gradient as part of the class.

    Since it is a just simple gradient, is there a reason you include it as an actual file rather than just creating it on-the-fly? I would think a completely self-encapsulated class would be preferable to one that relies on an external file being present would it not? Or is there some overhead or procedural reason to make a separate file and include it to which I'm unaware?
     
    Last edited: Mar 12, 2018
    Cableguy and davidvidasoft like this.
  3. Jack Cole

    Jack Cole Active Member Licensed User

    This is very useful. I highly recommend this for any countdown timers on Android. It looks good and it shows up as performing very quickly in Google's metrics that are used for Android vitals. This solves several problems for me. Thanks!
     
    Erel likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    Creating a gradient in B4J and B4i requires some non-trivial work so I preferred to use an image. The complete view was developed in less than 30 minutes as a response to a member question...
     
  5. Jeffrey Cameron

    Jeffrey Cameron Active Member Licensed User

    Fair enough, it's quite trivial to do in B4A and .NET, I just assumed it would be as easy to do in B4J/i as well. Just happy to know the choice is strictly a design concern, thanks for letting me know.

    I'm pretty sure you do more by 8am than I do all day :p
     
    Claudio Oliveira likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    I'm the most productive till 8am. I'm taking two girls to school and another one to the kindergarten :)
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    A new version was uploaded. It uses BitmapCreator to create the "fade" bitmap.

    Note that you can change its color in these two lines (CreateFadeBitmap sub):
    Code:
    bc.SetARGB(a, x, y, 255255255)
    bc.SetARGB(a, x, bc.mHeight - 
    1 - y, 255255255)
     
  8. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    with BitmapCreator is a "Type do not match" on:
    Code:
    Private Sub CreateFadeBitmap As B4XBitmap
        
    Dim bc As BitmapCreator
        bc.Initialize(
    20050)
        
    For x = 0 To bc.mWidth - 1
            
    For y = 0 To bc.mHeight / 2 - 1
                
    Dim a As Float = Max(01 - y / bc.mHeight * 3)
                bc.SetARGB(a, x, y, 
    255255255)
                bc.SetARGB(a, x, bc.mHeight - 
    1 - y, 255255255)
            
    Next
        
    Next
        
    Return bc.Bitmap
    End Sub
    Code:
    bc.SetARGB(a, x, y, 255255255)
    bc.SetARGB(a, x, bc.mHeight - 
    1 - y, 255255255)
     
    Erel likes this.
  9. Erel

    Erel Administrator Staff Member Licensed User

    New version uploaded. BitmapCreator module removed and the library is used instead. The code is a bit simpler as BitmapCreator has built-in support for gradients.
     
    asales and Alexander Stolte like this.
  10. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Any plans to add negativ numbers?

    insert a "-" instead of a "0"
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Try to add it. You can add a label with minus and show or hide it as needed in setValue.
     
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