B4A Library [B4X] [XUI] AnotherProgressBar

Status
Not open for further replies.
Edit: Latest version of AnotherProgressBar with several important improvements is available in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content

SS-2018-11-01_15.53.04.png


A simple, cross platform, indeterminate progress bar.

Depends on BitmapCreator v4.50+: https://www.b4x.com/android/forum/threads/b4x-xui2d-box2d-game-engine.95208/

It uses the new BitmapCreator async drawing features.

The relevant code is:
B4X:
Private Sub BusyLoop
   Dim MyIndex As Int = BusyIndex
   Do While MyIndex = BusyIndex
       If Vertical Then
           BusyBrush.SrcOffsetY = BusyBrush.SrcOffsetY + 3
       Else
           BusyBrush.SrcOffsetX = BusyBrush.SrcOffsetX - 3
       End If
       Dim tasks As List
       tasks.Initialize
       tasks.Add(bc.AsyncDrawRect(bc.TargetRect, TransparentBrush, True, 0))
       tasks.Add(bc.AsyncDrawRectRounded(bc.TargetRect, BusyBrush, True, 0, 15))
       bc.DrawBitmapCreatorsAsync(Me, "BC", tasks)
       Wait For BC_BitmapReady (bmp As B4XBitmap)
       If xui.IsB4J Then bmp = bc.Bitmap
       bc.SetBitmapToImageView(bmp, mIV)
       Sleep(16)
   Loop
End Sub

A B4A project is attached. The custom view class is inside.

Updates:

v1.01 - Fixes an issue with the label visibility.
 
Last edited:

asales

Expert
Licensed User
Longtime User
If I start the AnotherProgressBar with visible = False in the designer, the text is not show, when the progress become visible.

If I use "AnotherProgressBar1.Visible = False" in the code, after load the layout, works.

Why this behavior?
 

LordZenzo

Well-Known Member
Licensed User
Longtime User
does not work
I'll explain
start the progress bar before starting a cycle of calculations that can last a few minutes, and the progress bar remains stationary
it only moves if I replace the Sleep (16) with a deprecated DoEvents
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've removed your project based on DoEvents. This is a bad practice.

1. Latest version of AnotherProgressBar with several important improvements is available in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content

2. Read the instructions in that link. There is one line of code that should go in Activity_Resume.
 
Status
Not open for further replies.
Top