B4A Library NumberProgressBar V2.1.2

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Mar 29, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    This is a wrapper for this Github-project.
    This is a complete rewrite of the wrapper as i lost the source by accident.
    V2 includes CustomProperties for the Designer.

    NumberProgressBar
    Author:
    DonManfred (wrapper)
    Version: 2.11
    • NumberProgressBar
      Events:
      • onProgressChange (current As Int, maxvalue As Int)
      Fields:
      • ba As BA
      Methods:
      • BringToFront
      • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
      • Initialize (EventName As String)
      • Invalidate
      • Invalidate2 (arg0 As Rect)
      • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • IsInitialized As Boolean
      • RemoveView
      • RequestFocus As Boolean
      • SendToBack
      • SetBackgroundImage (arg0 As Bitmap)
      • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
      • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
      • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
      • dp2px (dp As Float) As Float
      • incrementProgressBy (by As Int)
      • sp2px (sp As Float) As Float
      Properties:
      • Background As Drawable
      • Color As Int [write only]
      • Enabled As Boolean
      • Height As Int
      • Left As Int
      • Max As Int
      • Parent As Object [read only]
      • Prefix As String
      • Progress As Int
      • ProgressTextColor As Int
        progress text color.
      • ProgressTextSize As Float
        progress text size.
      • ProgressTextVisible As Boolean
      • ReachedBarColor As Int
      • ReachedBarHeight As Float
      • Suffix As String
      • Tag As Object
      • Top As Int
      • UnreachedBarColor As Int
      • UnreachedBarHeight As Float
      • Visible As Boolean
      • Width As Int

    [​IMG]

    Code used in Example
    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.

        
    Private np1 As NumberProgressBar
        
    Private np2 As NumberProgressBar
        
    Private np3 As NumberProgressBar
        
    Dim t1, t2, t3 As Timer
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("Layout1")
        np1.incrementProgressBy(
    0)
        np1.ProgressTextColor = 
    Colors.Blue
        np1.ReachedBarColor = 
    Colors.Yellow
        np1.UnreachedBarColor = 
    Colors.Red
        np1.UnreachedBarHeight = 
    1dip
        np1.ReachedBarHeight = 
    5dip
        np1.Prefix = 
    "%"
        np1.Suffix = 
    ""
        t1.Initialize(
    "t1",50)
        t1.Enabled = 
    True

        np2.incrementProgressBy(
    0)
        np2.ProgressTextColor = 
    Colors.White
        np2.ReachedBarColor = 
    Colors.Green
        np2.UnreachedBarColor = 
    Colors.Red
        np2.UnreachedBarHeight = 
    5dip
        np2.ReachedBarHeight = 
    5dip
        t2.Initialize(
    "t2",60)
        t2.Enabled = 
    True

        np3.incrementProgressBy(
    0)
        np3.ProgressTextColor = 
    Colors.Green
        np3.ReachedBarColor = 
    Colors.Magenta
        np3.UnreachedBarColor = 
    Colors.LightGray
        np3.UnreachedBarHeight = 
    5dip
        np3.ReachedBarHeight = 
    1dip
        np3.Prefix = 
    "Prefix"
        np3.Suffix = 
    "Suffix"
        t3.Initialize(
    "t3",100)
        t3.Enabled = 
    True
    End Sub
    Sub t1_tick
        
    If np1.Progress <= 100 Then
            np1.incrementProgressBy(
    1)
        
    Else
            t1.Enabled = 
    False
        
    End If
    End Sub
    Sub t2_tick
        
    If np2.Progress <= 100 Then
            np2.incrementProgressBy(
    1)
        
    Else
            t2.Enabled = 
    False
        
    End If
    End Sub
    Sub t3_tick
        
    If np3.Progress <= 100 Then
            np3.incrementProgressBy(
    1)
        
    Else
            t3.Enabled = 
    False
        
    End If
    End Sub

    This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
    Please click here to donate (You can donate any amount you want to donate for the library (or my work) :)
    [​IMG]
     

    Attached Files:

    Last edited: May 8, 2016
    M Zuhri, paragkini, Procesor and 25 others like this.
  2. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you for share
     
  3. itgirl

    itgirl Active Member Licensed User

    DonManfred you are a great asset to this community i'v already used 3 of ur wrappers. thank you so much ;)
     
  4. luciano deri

    luciano deri Active Member Licensed User

    Is possible start by 100 and decrement to go at 0?
     
  5. DonManfred

    DonManfred Expert Licensed User

    Where is the problem?


    Old
    Code:
    Sub t1_tick
        
    If np1.Progress <= 100 Then
            np1.incrementProgressBy(
    1)
        
    Else
            t1.Enabled = 
    False
        
    End If
    End Sub
    New
    Code:
    Sub t1_tick
        
    If np1.Progress > 0 Then
            np1.Progress = np1.Progress -
    1
        
    Else
            t1.Enabled = 
    False
        
    End If
    End Sub
    Dont forget to start at 100 instead of 0
    Code:
    np1.Progress = 100
     
    luciano deri likes this.
  6. luciano deri

    luciano deri Active Member Licensed User

    ok Grazie.
     
  7. luciano deri

    luciano deri Active Member Licensed User

    Is possible make a max value otherwise at 100 and see this true number? I have done so
    Code:
    pvpers = 60
    CVpvpers.Max=pvpers
    CVpvpers.Progress = pvpers
    I vould like see a full bar but text value = 60
     
  8. delozoya

    delozoya Member Licensed User

    Hello, Thanks for your works.
    Is it possible to replace the number with the% , for a icon?
     
  9. DonManfred

    DonManfred Expert Licensed User

    The library does not expose such a feature. You can set a prefix and a suffix if i remember correctly.
     
  10. ArminKH

    ArminKH Well-Known Member

    is this possible to set ProgressText background color to transparent? that is always white
     
  11. hookshy

    hookshy Well-Known Member Licensed User

    Nice, tested on adroid Jelly Bean a huawei device
     
    DonManfred likes this.
  12. DonManfred

    DonManfred Expert Licensed User

    i´ll release a new version later today (hopefully) where you can set a background-color. The original lib does not set any... my first tryings (hardcoded) work. Need to write some code to include it into the lib...

    Edit: I looked at the result and thought; hmm, this looks like before!?
    So i removed my changes and try again....

    Same result. One of the bars in example showed a white unreachedbar... I´ll investigate more on this
     
    Last edited: Nov 5, 2015
    ArminKH likes this.
  13. ArminKH

    ArminKH Well-Known Member

    anyway thank u for your hard work fred ;)
     
  14. Dave O

    Dave O Active Member Licensed User

    Nice library. I was looking for a progress bar that let me set the max # and have more control over the visuals, and this does the job.

    Wish: Ability to set more properties in the designer instead of in code.

    Will donate now. Cheers!
     
  15. DonManfred

    DonManfred Expert Licensed User

    I´ll write another wrap for this as i accidently lost my wrap-source.

    Not a big deal.
    Will release it later today. Including B4A 5.8 Designerproperties. (Note i rewrote the wrapper in about 20 minutes now; but i need some additional time to add Designerproperties :) )

    But for now i need to go shopping as we want to have BBQ in the evening...
     
    Dave O likes this.
  16. DonManfred

    DonManfred Expert Licensed User

    Got it. Thank you very much :)
    Download V2 in Post #1 and try this one ;)
     
  17. Dave O

    Dave O Active Member Licensed User

    Just tried v2, but get an error on:

    searchPB.ProgressTextVisibility = False

    (where searchPB is the progress bar):

    error: incompatible types: boolean cannot be converted to ProgressTextVisibility
     
  18. DonManfred

    DonManfred Expert Licensed User

    i changed this method to expect boolean. Additional i changed the Propertxname from ProgressTextVisibility to ProgressTextVisible
    Code:
    searchPB.ProgressTextVisible = false
    should work now

    See #1 for Updated lib V2.1.0
     
  19. Dave O

    Dave O Active Member Licensed User

    Yes, that works, although the code auto-suggest now shows ProgressTextVisible as write-only and ProgressTextVisibility as read-only. Is that intentional, or did you forget to rename the getter method?

    Also, it would be nice to have ProgressTextVisible settable in the designer too.

    But in the meantime, nice control - definitely made my app better. Thanks! :)
     
  20. DonManfred

    DonManfred Expert Licensed User

    Gotcha :D
    Fixed in V2.1.1
    Included in 2.1.1 too (untested but should work)
     
    Leni Berry and Dave O 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