B4A Library CircleProgressMaster

Discussion in 'Additional libraries, classes and official updates' started by Johan Schoeman, Jul 4, 2015.

Similar threads

B4A Library PanoramaImageView
B4A Library SnakeView
B4A Library LEDView
B4A Library CircularProgress
B4A Library AnimatedCheckbox V1.0.1
  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    The attached project wraps this Github project. Library files are in the /files folder of the attached B4A project. Copy them to your additional libraries folder.
    The ArcProgress view (second from right) and the DonutProgress view indicate the actual battery level of my device. Have added some inline Java code to extract the battery level. It uses the JavaObject Library and I have therefore included JavaObject XML and JAR in the /files folder of the attached project (for in case someone don't have them or has an older version of it).
    Also attaching the Java source code (src.zip)
    Thanks teacher....;)

    Edit: See update in post #6


    pic2.png

    CircleProgressMaster
    Version:
    1
    • ArcProgressMaster
      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:
      • ArcAngle As Float
      • Background As Drawable
      • BottomText As String
      • BottomTextSize As Float
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedStrokeColor As Int
      • Height As Int
      • Left As Int
      • Max As Int
      • Progress As Int
      • StrokeWidth As Float
      • SuffixText As String
      • SuffixTextPadding As Float
      • SuffixTextSize As Float
      • Tag As Object
      • TextColor As Int
      • TextSize As Float
      • Top As Int
      • UnfinishedStrokeColor As Int
      • Visible As Boolean
      • Width As Int
    • CircleProgressMaster
      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
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedColor As Int [write only]
      • Height As Int
      • Left As Int
      • Max As Int [write only]
      • PrefixText As String [write only]
      • Progress As Int [write only]
      • SuffixText As String [write only]
      • Tag As Object
      • TextColor As Int [write only]
      • TextSize As Float [write only]
      • Top As Int
      • UnfinishedColor As Int [write only]
      • Visible As Boolean
      • Width As Int
    • DonutProgressMaster
      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
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedStrokeColor As Int
      • FinishedStrokeWidth As Float
      • Height As Int
      • InnerBackgroundColor As Int
      • InnerBottomText As String
      • InnerBottomTextColor As Int
      • InnerBottomTextSize As Float
      • Left As Int
      • Max As Int
      • PrefixText As String
      • Progress As Int
      • SuffixText As String
      • Tag As Object
      • Text As String
      • TextColor As Int
      • TextSize As Float
      • Top As Int
      • UnfinishedStrokeColor As Int
      • UnfinishedStrokeWidth As Float
      • Visible As Boolean
      • Width As Int
     

    Attached Files:

    Last edited: Jul 15, 2015
  2. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Have completed the project and posted new files in post #1. Was a bit easier than what I anticipated. Note that library files are in the /files folder of the B4A project
     
    Kwame Twum likes this.
  3. ArminKH

    ArminKH Well-Known Member

    SO Beautiful :) thank u
     
    Johan Schoeman likes this.
  4. cambopad

    cambopad Active Member Licensed User

    The third style is beautiful! Thanks for the share!
     
    Johan Schoeman likes this.
  5. cbc551

    cbc551 Member Licensed User

    Hi! There is a chance to change in which angle begins the progress on donut?

    It always starts at the angle 0 (right of donut), would be great to have the option of deciding the starting angle, eg, 90 (above)

    Sorry for my English. Thanks
     
  6. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Here you go. New library files are in the /files folder of the B4A project. Copy them to your additional libraries folder. The attached B4A project demonstrates only the DonutProgressMaster with starting points at 0, 90, 180, and 270 degrees. Other code relating to the CircleProgress and ArcProgress have been commented out. Also posting the updated java source code.

    pic3.png


    CircleProgressMaster
    Version:
    1
    • ArcProgressMaster
      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:
      • ArcAngle As Float
      • Background As Drawable
      • BottomText As String
      • BottomTextSize As Float
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedStrokeColor As Int
      • Height As Int
      • Left As Int
      • Max As Int
      • Progress As Int
      • StrokeWidth As Float
      • SuffixText As String
      • SuffixTextPadding As Float
      • SuffixTextSize As Float
      • Tag As Object
      • TextColor As Int
      • TextSize As Float
      • Top As Int
      • UnfinishedStrokeColor As Int
      • Visible As Boolean
      • Width As Int
    • CircleProgressMaster
      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
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedColor As Int [write only]
      • Height As Int
      • Left As Int
      • Max As Int [write only]
      • PrefixText As String [write only]
      • Progress As Int [write only]
      • SuffixText As String [write only]
      • Tag As Object
      • TextColor As Int [write only]
      • TextSize As Float [write only]
      • Top As Int
      • UnfinishedColor As Int [write only]
      • Visible As Boolean
      • Width As Int
    • DonutProgressMaster
      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
      • Color As Int [write only]
      • Enabled As Boolean
      • FinishedStrokeColor As Int
      • FinishedStrokeWidth As Float
      • Height As Int
      • InnerBackgroundColor As Int
      • InnerBottomText As String
      • InnerBottomTextColor As Int
      • InnerBottomTextSize As Float
      • Left As Int
      • Max As Int
      • PrefixText As String
      • Progress As Int
      • StartAngle As Int [write only]
      • SuffixText As String
      • Tag As Object
      • Text As String
      • TextColor As Int
      • TextSize As Float
      • Top As Int
      • UnfinishedStrokeColor As Int
      • UnfinishedStrokeWidth As Float
      • Visible As Boolean
      • Width As Int
     

    Attached Files:

  7. cbc551

    cbc551 Member Licensed User

    Great! Thank you!
     
  8. Harris

    Harris Well-Known Member Licensed User

    Very nice....
    I have tried others but this is so much LESS complex and all inclusive.

    I do notice that one must invalidate the view else progress value text becomes a mess (98 will stack up on 97, 96, 95 and so on).

    The code below is run on a timer (every 30 seconds)
    Code:
    Sub IncPB1(np1 As ArcProgressMaster, val As Int, mymax As Int)

        
    Dim remain, maxVal, vdip As Int
        maxVal = mymax
          
        vdip = (val / maxVal) * 
    100
        remain = 
    100 - vdip
        np1.Progress = remain

        
    If (remain >= 15And (remain <= 200Then
                   np1.FinishedStrokeColor = 
    Colors.RGB(76,152,0' a nice green...
        Else If    (remain >= 10And (remain < 15Then
                   np1.FinishedStrokeColor = 
    Colors.Yellow
        
    Else
                   np1.FinishedStrokeColor = 
    Colors.Red
        
    End If
     
        np1.Invalidate

    End Sub
    WAIT.... Even with Invalidate the center value text is not clearing...
    Very odd indeed... I must be doing something wrong.... Seems to happen when value gets below 90 percent????
    See pic attached...

    Thanks


    overwrite.png
     

    Attached Files:

  9. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Have just tried the code below and seems to be working fine. Will look into your example when back from work this afternoon..

    Code:
    #Region  Project Attributes
        
    #ApplicationLabel: Harris
        
    #VersionCode: 1
        
    #VersionName:
        
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
        
    #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 cv1 As ArcProgressMaster
        
    Dim cnt As Int = 0
    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",200)
        cv1.FinishedStrokeColor = 
    Colors.Green
        cv1.StrokeWidth = 
    10
        cv1.Max = 
    200
        cv1.BottomText = 
    "Testing"
        cv1.BottomTextSize = 
    20
        cv1.SuffixText = 
    "  (a value)"
        cv1.SuffixTextSize = 
    20

    End Sub

    Sub Activity_Resume

    t.Enabled = 
    True

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    t.Enabled = 
    False

    End Sub
    Sub t_tick

    cnt = cnt + 
    1
    If cnt = cv1.Max Then cnt = 0
    cv1.Progress = cnt

    End Sub
     
  10. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Solution:

    Don't declare np1 As ArcProgressMaster in Sub IncPB1. np1 (or whatever you might have used as a variable name in your declaration) should be declared in Sub Globals and will then be visible throughout the B4A main module code.

    Change
    Sub IncPB1(np1 As ArcProgressMaster, val As Int, mymax As Int)
    to
    Sub IncPB1(val As Int, mymax As Int)

    and don't pass np1 (or whatever you might have used as a variable name in your declaration) as a parameter from the timer sub that calls Sub IncPB1. Use the variable name that you have declared in Sub Globals through out the B4A main module code.
     
    Harris likes this.
  11. Harris

    Harris Well-Known Member Licensed User

    It has been solved.
    I was incorrectly adding this view in code over and over again - without removing the original view.

    Thanks to Johan for pointing this out. The lib works great!
     
    Johan Schoeman likes this.
  12. aidymp

    aidymp Active Member Licensed User

    Hi,

    Is it possible to use this in B4J?

    Thanks

    Aidy
     
  13. ArminKH

    ArminKH Well-Known Member

    It's using android api
     
    Johan Schoeman and aidymp like this.
  14. Kwame Twum

    Kwame Twum Active Member Licensed User

    Hello everyone,
    I tired to update progress of a DonutProgressMaster in a listview from a service..

    Code:
    'Call from service
    Sub download_Progress(progressvalue As Long, index As int)
    If IsPaused(ActivityName) = False Then CallSub3(ActivityName, "Report_Prog",progressvalue,index)
    Code:
    'ACTIVITY - (ActivityName)
    Sub Report_Prog(value As Long,index As Int)
        
    Try
            
    Dim pon As Panel = cv.GetPanel(index)
            
    Dim card As MSCardView = pan.GetView(0)        'There's a cardview on the panel holding the DonutProgressMaster
            Dim prga As DonutProgressMaster = card.Panel.GetView(2)         'The DonutProgressMaster is the 3rd view on the cardview's panel
            prga.Progress = value
            
    Return
        
    Catch
            
    Log(LastException)
        
    End Try
    End Sub
    I get the following during compile:
    Code:
    error: cannot find symbol
    mostCurrent._prga.setObject((main.java.com.github.lzyzsd.circleprogress.DonutProgress)(_codx.getPanel().GetView((int) (
    2)).getObject()));
      symbol:   class java
      
    location: class main
    Kindly note that this works when the respective view is a ProgressBar and not a DonutProgressMaster.
     
  15. BarryW

    BarryW Active Member Licensed User

    Is there any animation on change of value in ArcProgressMaster... Tnx
     
  16. panagiotisden2

    panagiotisden2 Member Licensed User

    hey Johan!
    is it possible to change the side of the filled space?
    let me explain it.
    i want to convert this
    pic2.png

    to this(done in photoshop)


    pic22.png

    and the text to still be 47% not 53%?

    thank you.
     
  17. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Try with the attached library files. Use it is follows:
    Code:
    apm1.UseReverse = True    'or false
    1.png
     

    Attached Files:

  18. Johan Schoeman

    Johan Schoeman Expert Licensed User

    See post #17
     
  19. panagiotisden2

    panagiotisden2 Member Licensed User

    You are awsome!!
    Thanks a lot johan! ;)
     
    Johan Schoeman likes this.
  20. Sapta

    Sapta Member Licensed User

    Hi @Johan Schoeman
    How to be able to display floating value like 98.02 % ?
    Thank you
     
Loading...