B4A Library [Lib] CustomProgressDialog

This library will allow you to customize a Progress Dialog.

Requirements:

- B4A 3.x

How to install:

- Copy the CustomProgressDialog.jar and CustomProgressDialog.xml to your additional libraries directory.

How to use:

B4X:
'Initialize the library
Dim myProgressDialog As CustomProgressDialog

'Create your ProgressDialog
'Leaving the animation parameter blank will display the default spinner.
'Entering -1 on LEFT or TOP parameters will center the CustomProgressDialog
myProgressDialog.Initialize(Activity, 95%x, -1, -1, "", Colors.DarkGray, 0, "")  

'Display it
myProgressDialog.Show("Tap the BACK key to stop...", Colors.White)

B4X:
'Hide/Close the CustomProgressDialog
myProgressDialog.Hide

That's it!!

The included animations are: Spinner, Laser, Bounce, Domino and Holo.


You can also customize a ProgressDialog with a ProgressBar, look at the attached sample for more details.

NOTE: Updated to version 2.20, added a new animation named "Holo".
 

Attachments

  • CustomProgressDialog_Sample.zip
    13 KB · Views: 1,333
  • CustomProgressDialog_Lib_2.20.zip
    19.1 KB · Views: 1,408
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
How do I center it now. Vertical and Horizontal? I do not know the height of the Progress Dialog.


I tried this for Horizontal and does not center. Bug?

B4X:
cProgressBounce.Initialize(Activity, 60%x, 20%x, 50%y, "", Colors.DarkGray, Colors.Cyan, "Bounce")


Update: Ok, -1 centers it, but I still would double check the left and top property. It should of center Horizontally with the values above.
 
Last edited:

melamoud

Active Member
Licensed User
Longtime User
The sample uses a timer which will stop when the progress reaches 100%, that's why you see that effect, that's just for illustration purposes you can adapt it any way you like it.

HI,

I'm not using your example, , your example worked for me, but in my project it get frozen (the animation)
my code is calling hide, and then hide the panel I was at, and make the main activity visible, all that does not happen until my sql async call is complete and I call hide again - this make no sense, can you explain ?
 

melamoud

Active Member
Licensed User
Longtime User
what worked for me, is to ignore the back key pressed which is not what I wanted to do, but its good enough for now

I did this
B4X:
Sub activity_KeyPress (KeyCode As Int) As Boolean 
   
   If KeyCode = KeyCodes.KEYCODE_BACK Then
      If (WaitDialog.IsInitialized AND WaitDialog.IsShow) Then Return True ' handled it dont do anything
   End If

Sub end
 

NJDude

Expert
Licensed User
Longtime User
How do I center it now. Vertical and Horizontal? I do not know the height of the Progress Dialog.


I tried this for Horizontal and does not center. Bug?

B4X:
cProgressBounce.Initialize(Activity, 60%x, 20%x, 50%y, "", Colors.DarkGray, Colors.Cyan, "Bounce")


Update: Ok, -1 centers it, but I still would double check the left and top property. It should of center Horizontally with the values above.

Ok, I have modified the lib, now the -1 is independent for each values, in other words say that you want the dialog centered HORIZONTALLY and at 50dip from the top, so you should do this:
B4X:
cProgressBounce.Initialize(Activity, 60%x, -1, 50dip, "", Colors.DarkGray, Colors.Cyan, "Bounce")

if you want it centered VERTICALLY and 10dip from the left then do this:
B4X:
cProgressBounce.Initialize(Activity, 60%x, 10dip, -1, "", Colors.DarkGray, Colors.Cyan, "Bounce")

50%x or 50%y won't center the dialog on the screen since those are the values for LEFT and TOP not centering.
 
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
NJ,

Is there a way to show all characters in the Progressbar Status. 30 and over Characters on a small screen will not show completely. Perhaps, Expand the height of the label and append it below?

Thanks
 

Rigsby

Member
Licensed User
Longtime User
This is a non-modal ProgressDialog.

Hi,

The custom progress dialog look great, cheers, problem I have is all the command buttons in my app are unavailable whilst it is running. So I can't click an Abort button I have - I have to press the back key. Why can't I click one of the app buttons if it's non-modal ?

Or is there way to have a command button on the dialog that will run a Main sub - you could get it to hide and run the sub ?

Cheers
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi NJDude,
I've just download your lib v1.8,but I've this error.How do I do?
Best Regards
Theera
 
Last edited:

chjk

Member
Licensed User
Longtime User
I want the CustomProgressDialog is completely transparent, but it is translucent

myProgressDialog.Initialize(Panel1, Panel1.Width, 0, -20, "", Colors.Transparent, Colors.Transparent, "")
myProgressDialog.Show("Tap the BACK key to stop...", Colors.Black)

Hope to be able to modify the lib, make it completely transparent, thanks
I need completely transparent Progressdialog
 

Shay

Well-Known Member
Licensed User
Longtime User
Hi

I wish to have counter down, so I wrote:
B4X:
Sub TimerClock_Tick
 
    Seconds=Seconds-1
    'Entering -1 on LEFT or TOP parameters will center the CustomProgressDialog
                myProgressDialog.Initialize(Activity, 95%x, -1, -1, "", Colors.DarkGray, 0, "")
                myProgressDialog.Show(Seconds, Colors.White)
    If Seconds=0 Then
    TimerClock.Enabled = False
    End If
  
End Sub

but the counter is on the right side of the circle
is it possible to put the counter inside the circle?
(I probably can put label on top of this, but i was looking for built-in solution)

thanks
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Is there a way to provide a 9-patch for the panel, and images for the animations? Cause this isn't really custom...
 

NJDude

Expert
Licensed User
Longtime User
Is there a way to provide a 9-patch for the panel, and images for the animations? Cause this isn't really custom...
It is custom, and not because doesn't do what YOU want means that is not custom, so, let's be clear about the technicalities.

You can change the background image, and the color of the animations, however there's no simple way to change the animations.
 
Last edited:
Top