B4A Library [Lib] CustomProgressDialog

Discussion in 'Additional libraries, classes and official updates' started by NJDude, Mar 16, 2013.

  1. NJDude

    NJDude Expert Licensed User

    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:

    Code:
    '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(Activity95%x, -1, -1""Colors.DarkGray, 0"")  

    'Display it
    myProgressDialog.Show("Tap the BACK key to stop..."Colors.White)
    Code:
    '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".
     

    Attached Files:

    Last edited: Jun 23, 2014
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Really nice and useful.
    Are those panels?
     
  3. melamoud

    melamoud Active Member Licensed User

    is the anoimation works in the UI thread ? so I cant use ths on blocking operations ?
     
  4. NJDude

    NJDude Expert Licensed User

    This is a non-modal ProgressDialog.
     
    lorebarita likes this.
  5. Jaames

    Jaames Active Member Licensed User

    Very nice. Thanks for sharing! :icon_clap:
     
  6. melamoud

    melamoud Active Member Licensed User

    Not sure I understood your answer.
    Can I call show ans then run a long blocking sql query and when its done call hide

    Will I see the animation while the query run?

    Thanks.
     
  7. NJDude

    NJDude Expert Licensed User

    Yes you should.
     
  8. Scantech

    Scantech Active Member Licensed User

    Wow. very nice.
     
  9. moster67

    moster67 Expert Licensed User

    Very nice NJ! :icon_clap:

    Tested on JB and GB - this will be very useful.

    Thanks for sharing
     
  10. Scantech

    Scantech Active Member Licensed User

    NJ,

    Is there a way to bring the progress dialog to the front without the need to reinitialize? BringtoFront property is needed in my situation.

    When you use the progress dialog, hide it, then if any views are brought up to front, it will make the progress dialog hidden behind the view (listview in my situation).

    Otherwise, I like it so far and just what i was looking for.

    Thank you
     
  11. NJDude

    NJDude Expert Licensed User

    Library updated to version 1.2 to fix the issue Scantech mentioned above.
     
  12. Scantech

    Scantech Active Member Licensed User

    Thanks NJ. Latest version fixed it.

    However, using Bounce/Laser and continuously changing the message causes the drawing to jitter or off place. If you understand what I am trying to say. Nice, smooth back and forth motion will be nice. Only happens when changing message rapidly one after another. It's not a big deal, but thought I mentioned it.

    Thanks again!
     
  13. NJDude

    NJDude Expert Licensed User

    Yes, the Laser, Bounce or Domino animations are meant to be for static messages, however, I'll try to see if I can improve the code to do what you mentioned.
     
  14. Mahares

    Mahares Well Known Member Licensed User

    Thank you NJDude. You are a powerhouse.
    1. I tried to use it in conjunction with the Table class to display a query result set. If the btnLoadTable is automaticaly activated inside the Activity_Create, the laser, domino and bounce effects do not show. I can only see a static message, although I do not change the message. If I manually click the button, it shows the animation effect, albeit sluggish.
    2. The ability to position the location of the progress dialog, other than in the center of the screen if possible, may also be desirable in ceratin situations.

    Code:
    btnLoadTable_Click  'In Activity_Create: automatically display table at start-up

    Code:
    Sub btnLoadTable_Click
          
       myProgressDialog.Initialize(
    Activity95%x""Colors.DarkGray, Colors.Cyan, "Laser"
       myProgressDialog.Show(
    "Stand by. Lots of records"Colors.White)   

      Table1.Clear
       
    For i=0 To Cursor1.RowCount-1
             Cursor1.Position=i
                 Table1.AddRow(
    Array As String(Cursor1.GetString(Col_Name(0)), Cursor1.GetString(Col_Name(1)), _ 
             Cursor1.GetString(Col_Name(
    2)),Cursor1.GetString(Col_Name(3)), _
             Cursor1.GetString(Col_Name(
    4)),Cursor1.GetString(Col_Name(5)), _
             Cursor1.GetString(Col_Name(
    6)),Cursor1.GetString(Col_Name(7)), _
             Cursor1.GetString(Col_Name(
    8)),Cursor1.GetString(Col_Name(9)), _
             Cursor1.GetString(Col_Name(
    10)), Cursor1.GetString(Col_Name(11)) ))
             
    If i Mod 50 =0 Then DoEvents
       
    Next

                myProgressDialog.Hide
    End sub
     
  15. NJDude

    NJDude Expert Licensed User

    You might need to add a DoEvents after or before the Dialog show, regarding the positioning, I'll put that on my To Do list, maybe having default = center, or selecting Top and Bottom.
     
  16. Informatix

    Informatix Expert Licensed User

    I tried and the answer is No. If you can't call DoEvents, the spinner does not spin.
     
  17. Mahares

    Mahares Well Known Member Licensed User

    @ NJDude: I tried Doevents before and after the show progress, but neither helps. I think it has to do with the static animations: Laser, Domino and Bounce/ if you leave the animation BLANK as in the conventional progress, it is OK.
    Please also, see Freddy's ( Informatix: Happy Birthday Fred) post as I pre-empted it.
     
  18. thedesolatesoul

    thedesolatesoul Expert Licensed User

    From the android guidelines, you should run long blocking statements on another thread. Erel added async querries so I think you can use those.
    The fact is that the thread is blocked, and the ProgressDialog is on the same thread (and it has to be since it is the UI thread).
     
  19. melamoud

    melamoud Active Member Licensed User

    pressing back

    hi,

    is it possible that the lib is doing something with the back key ?
    I'm pressing back in the middle of the progress run, and it get frozen,
    I tried to catch the backkey (in the acitivity) and call hide, the call did nothing,

    BTW when my action (async SQL) finished and I called hide it worked,

    any idea ?
     
  20. NJDude

    NJDude Expert Licensed 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.
     
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