B4A Library ArrowDownloadButton

It wraps this Github project. Posting the B4A project, the Java code, and the B4A library files. It is quite a nice progress indicator.

Note the following:
1. It is for API 16+
2. For API 16+ the progress text will automatically show.
3. For API < 16 the progress text will not show automatically. For API < 16 I have added a transparent label over the customview that will show the progress text.
4. For API 16+ you just need to set the Visibility of the label to False in Activity_Create (see the code)

Some sample code:

#Region  Project Attributes
    #ApplicationLabel: ArrowDownloadButton
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim t, t1 As Timer

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private adb1 As ArrowDownloadButton
    Dim cnt As Float = 0
    Private Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    t.Initialize("t", 100)
    t1.Initialize("t1", 2000)
    adb1.RingColor = Colors.Blue
    adb1.ProgressColor = Colors.yellow
    adb1.ProgressTextColor = Colors.white
    adb1.ArcWidth = 30
    adb1.ProgressTextSize = 60
    Label1.Visible = True
    Label1.Color = Colors.Transparent
    Label1.TextColor = Colors.White
    Label1.TextSize = 30   
End Sub

Sub Activity_Resume
    t1.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    t.Enabled = False

End Sub
Sub t_tick
    If cnt < 101 Then
'      Log(adb1.Progress)   
      cnt = cnt + 1
      adb1.Progress = cnt
      Label1.Text = cnt & "%"
      cnt = 0
      t.Enabled = False
      Label1.Text = ""
    End If   
End Sub

Sub t1_tick

t.Enabled = True
t1.Enabled = False   
End Sub




Johan Schoeman
Version: 1
  • ArrowDownloadButton
    • ba As BA
    • 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)
    • reset
      reset to initial state
    • startAnimating
      start animating before loading
    • ArcWidth As Float [write only]
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Progress As Float
    • ProgressColor As Int [write only]
    • ProgressTextColor As Int [write only]
    • ProgressTextSize As Float [write only]
    • RingColor As Int [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int


  • TheJavaCode.zip
    20.1 KB · Views: 205
  • b4aLibraryFiles.zip
    10.9 KB · Views: 229
  • b4aArrowDownloadButton.zip
    8.2 KB · Views: 283