B4A Library JSSimpleArcLoader - new progress dialog/loader

"bored of seeing the same old Android Loader? SimpleArcLoader is one thing you should try"

This is a wrap of SimpleArcLoader library: https://github.com/generic-leo/SimpleArcLoader

And will share it to you guys "as-is".
Designer Custom View Supported.


simplearcdialog_1.gif

simplearcdialog_2.gif



Classes:
  • JSArcConfiguration - configure colors, width and text of your loader
  • JSSimpleArcDialog (DIALOG)
  • JSSimpleArcLoader (VIEW) - Add it to activity, panel, or layout (designer)

JSSimpleArcLoader
Version:
0.3
  • JSArcConfiguration
    Fields:
    • STYLE_COMPLETE_ARC As Int
    • STYLE_SIMPLE_ARC As Int
    Methods:
    • Initialize
    • IsInitialized As Boolean
    Properties:
    • AnimationSpeed As Int [write only]
    • AnimationSpeedWithIndex As Int [write only]
    • ArcMargin As Int [write only]
    • ArcWidthInPixel As Int [write only]
    • Colors() As Int [write only]
    • LoaderStyle As Int [write only]
    • Text As String [write only]
    • TextColor As Int [write only]
    • TextSize As Int [write only]
    • TypeFace As Typeface [write only]
  • JSSimpleArcDialog
    Events:
    • OnDismiss
    Methods:
    • Dismiss
      Dismiss ArcDialog
    • Initialize (eventName As String)
      Initialize JSSimpleArcDialog
      ba:
      eventName:
    • Initialize2 (eventName As String, config As JSArcConfiguration)
      Initialize JSSimpleArcDialog
      ba:
      eventName: event name
      config: JSArcConfiguration
    • IsInitialized As Boolean
    • IsShowing As Boolean
      Check if dialog is showing
      Return type: @return:IsShowing
    • Show (Cancelable As Boolean)
      Show JSSimpleArcDialog with default configuration
    • Show2 (config As JSArcConfiguration, Cancelable As Boolean)
      Show JSSimpleArcDialog with custom configuration
      config: JSArcConfiguration
      Cancelable:
  • JSSimpleArcLoader
    Methods:
    • BringToFront
    • DesignerCreateView (paramPanelWrapper As PanelWrapper, paramLabelWrapper As LabelWrapper, paramMap As Map)
    • Initialize
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • IsRunning As Boolean
      Checks if ArcLoader is running.
      Return type: @return:true, if successful
    • 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)
    • Start
      Start ArcLoader animation.
    • Stop
      Stop ArcLoader animation.
    • refreshArcLoaderDrawable (configuration As JSArcConfiguration)
      Refresh ArcLoader configuration.
      configuration: JSArcConfiguration
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int


B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim size As Int = Activity.Width / 2 - 15%x / 2
    Dim left As Int = 5%x
    Dim top As Int = 10%y

    '-----------
    Dim arc1 As JSSimpleArcLoader
    arc1.Initialize
    Activity.AddView(arc1, left, top, size, size)

    '-----------
    left = arc1.Left + arc1.Width + 5%x
    Dim arc2 As JSSimpleArcLoader
    arc2.Initialize

    Dim config As JSArcConfiguration
    config.Initialize
    config.LoaderStyle = config.STYLE_COMPLETE_ARC

    arc2.refreshArcLoaderDrawable(config)
    Activity.AddView(arc2, left, top, size, size)

    '-----------
    top = arc2.Top + arc2.Height + 5%x
    left = 5%x
    Dim arc3 As JSSimpleArcLoader
    arc3.Initialize

    Dim config As JSArcConfiguration
    config.Initialize
    config.LoaderStyle = config.STYLE_SIMPLE_ARC
    config.Colors = Array As Int(0xFFE91E63)
    arc3.refreshArcLoaderDrawable(config)
    Activity.AddView(arc3, left, top, size, size)

    '-----------
    left = arc3.Left + arc3.Width + 5%x
    Dim arc4 As JSSimpleArcLoader
    arc4.Initialize

    Dim config As JSArcConfiguration
    config.Initialize
    config.LoaderStyle = config.STYLE_COMPLETE_ARC
    config.Colors = Array As Int(0xFFE91E63, 0xFF3F51B5, 0xFF9C27B0)
    arc4.refreshArcLoaderDrawable(config)
    Activity.AddView(arc4, left, top, size, size)

    '----------
    top = arc4.Top + arc4.Height + 10dip
    Dim btnShowDialog As Button
    btnShowDialog.Initialize("btnShowDialog")
    Activity.AddView(btnShowDialog, 20dip, top, 100%x - 40dip, 56dip)
    btnShowDialog.Text = "Show ArcDialog"

End Sub

Sub btnShowDialog_Click
    Try
        Dim config As JSArcConfiguration
        config.Initialize
        config.LoaderStyle = config.STYLE_COMPLETE_ARC
        config.Colors = Array As Int(0xFFE91E63, 0xFF3F51B5, 0xFF9C27B0, 0xFFFFC107, 0xFFF44336, 0xFF4CAF50, 0xFF03A9F4)

        config.Text = "Loading..Please wait..."
        Dim dlg As JSSimpleArcDialog
        dlg.Initialize("dlg")
        dlg.Show2(config, True)        
    Catch
        Log(LastException)
    End Try
End Sub

Sub dlg_OnDismiss
    ToastMessageShow("dismiss", False)
End Sub

Just extract the content of the zip (including AAR) in your Additional Library folder.
 

Attachments

  • JSSimpleArcLoader_R1.zip
    29.6 KB · Views: 678
  • JSSimpleArcLoader_R2.zip
    30.6 KB · Views: 553
  • JSSimpleArcLoader_R3.zip
    33.8 KB · Views: 799
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Hi @SNOUHyhQs2 Thank you for this library.
When i try your example i have this error:

upload_2016-12-12_18-40-19.png


** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (B4A line: 34)
arc1.Initialize
java.lang.RuntimeException: Object should first be initialized (JSSimpleArcLoader).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:71)
at com.salvadorjhai.widgets.JSSimpleArcLoader.Initialize(JSSimpleArcLoader.java:64)
at b4a.example.main._activity_create(main.java:388)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 

MarcoRome

Expert
Licensed User
Longtime User
Hi @SNOUHyhQs2
Can you add type ProgressiDialog2("message...", False) The second argument specifies whether the user can dismiss the dialog by pressing on the Back key.
Thank you for your answer
Marco
 
Top