B4A Library NumberProgressBar V3

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: 3
  • 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

687474703a2f2f7777332e73696e61696d672e636e2f6d773639302f36313064633033346a77316566797264386e376937673230637a30326d7135662e676966


Code used in Example
B4X:
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) :)
 

Attachments

  • NumberProgressBar_example.zip
    21.6 KB · Views: 414
  • NumberProgressBarV3.0.zip
    13.8 KB · Views: 423
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi @DonManfred

I am having issues with this. If you see below I have created a very simple project and if I add the progressbar via the designer it errors out. If I remove it then all is good. Thanks for all your hard work!

upload_2016-5-8_19-54-13.png
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
That is the code in the picture. I had an issue in a larger project so I created a test project and that is what you see. I zipped it and it is attached.

Thanks.
 

Attachments

  • code.zip
    7.6 KB · Views: 241

Dave O

Well-Known Member
Licensed User
Longtime User
Hmm, just upgraded from 2.10 to 2.11 and I'm getting the same error.
 

Dave O

Well-Known Member
Licensed User
Longtime User
Confirmed, v2.1.2 is now compiling and running well.

I did notice 2 minor oddities: If I set Color or Visible in the designer, those settings are ignored. If I set them in code, they work properly.
 

Fausto Loss

Member
Licensed User
Hi Don, thanks this lib !!!

I have a problem (used v 2.1.2), please help !
 

Attachments

  • error.txt
    2.2 KB · Views: 227

Fausto Loss

Member
Licensed User
There is still a small problem:
the message
Lib: NOTFOUND 'numberprogress_onprogresschange
Appears several times.
 

Fausto Loss

Member
Licensed User
See the beginners guide how to work with the designer and how to create the event-sub. This is B4A in it´s basics
You can even create the sub manually.

B4X:
Sub NumberProgress_onProgressChange(current As Int, maxvalue As Int)
  
End Sub
Thanks ! Works Fine !
 

Metalika

Member
hi @DonManfred
unfortunately this lib dont work any more and i cant find any same lib
i run your example and encourage with this error:

B4X:
** Activity (main) Create, isFirst = true **
Error occurred on line: 34 (Main)
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.example.main._activity_create(main.java:386)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:104)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5305)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at de.donmanfred.NumberProgressBarWrapper.DesignerCreateView(NumberProgressBarWrapper.java:49)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 21 more
** Activity (main) Resume **
 

Metalika

Member
Please try again with V3 of the lib. See #1
I Think This lib Have A Problem :
how i can set Max value in this lib For a Progress Bar ?Default value for max method set to 100 and i want to change that.
This lib have Max Method( Max As Int ) , But not Work (Probably for Interferences)
 
Last edited:
Top