B4A Library SectorProgressView

A wrap for this Github project (a two-in-one). Posting the following:
1. B4A library files
2. B4A sample project
3. The Java code - change it to which ever way you like.

1.gif


Library:
SectorProgressView
Author:
Github: Tim Qi, Wrapped by: Johan Schoeman
Version: 1
  • ColorfulRingProgressView
    Fields:
    • ba As BA
    Methods:
    • 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)
    Properties:
    • Background As Drawable
    • BgColor As Int [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • FgColorEnd As Int [write only]
    • FgColorStart As Int [write only]
    • Height As Int
    • Left As Int
    • Padding()() As Int
    • Parent As Object [read only]
    • Percent As Float [write only]
    • StartAngle As Float [write only]
    • StrokeWidth As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • SectorProgressView
    Fields:
    • ba As BA
    Methods:
    • 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)
    Properties:
    • Background As Drawable
    • BgColor As Int [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • FgColor As Int [write only]
    • Height As Int
    • Left As Int
    • Padding()() As Int
    • Parent As Object [read only]
    • Percent As Float [write only]
    • StartAngle As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aSectorProgressView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #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 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 spv1 As SectorProgressView
    Dim cntr As Int = 0
    Private Label1 As Label
    Private cfrpv1 As ColorfulRingProgressView

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")

    t.Initialize("t", 100)

    spv1.BgColor = Colors.White
    spv1.FgColor = Colors.Red
    spv1.StartAngle = 0
    spv1.Percent = cntr
    Label1.Text = "" & cntr

    cfrpv1.BgColor = Colors.White
    cfrpv1.StartAngle = 0
    cfrpv1.StrokeWidth = 40
    cfrpv1.FgColorStart = Colors.Red
    cfrpv1.FgColorEnd = Colors.Yellow
    cfrpv1.Percent = cntr


End Sub

Sub Activity_Resume

    t.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)

    t.Enabled = False

End Sub

Sub t_tick

    cntr = cntr + 1
    If cntr < 101 Then
      spv1.Percent = cntr
      cfrpv1.Percent = cntr
      Label1.Text = "" & cntr
    Else
      cntr = 0
      spv1.Percent = cntr
      cfrpv1.Percent = cntr
      Label1.Text = "" & cntr
    End If

End Sub

Visual Designer Code:
B4X:
'All variants script
AutoScaleAll

spv1.Height = 40%y
spv1.Width = 40%y
spv1.left = 50%x - (spv1.Width/2)
spv1.Top = 2%y

Label1.Left = spv1.Left
Label1.Top = spv1.Bottom + 2%y
Label1.Width = spv1.Width
Label1.Height = 8%y

cfrpv1.Left = spv1.Left
cfrpv1.Top = Label1.Bottom + 2%y
cfrpv1.Width = spv1.Width
cfrpv1.Height = spv1.Height
 

Attachments

  • TheJavaCode.zip
    19 KB · Views: 323
  • b4aLibFiles.zip
    10.9 KB · Views: 376
  • b4aSectorProgressView.zip
    8.4 KB · Views: 340
Last edited:
Top