Hi everyone,
I have modified a CustomView based on the CircularProgressBar and am struggling to disable it's visibility.
I can set and get the 'Visible' property (and it returns False when set to false), but my problem is that it remains visible the whole time. Any ideas where I'm going wrong?
Thanks!
Here's the code:
I have modified a CustomView based on the CircularProgressBar and am struggling to disable it's visibility.
I can set and get the 'Visible' property (and it returns False when set to false), but my problem is that it remains visible the whole time. Any ideas where I'm going wrong?
Thanks!
Here's the code:
B4X:
#DesignerProperty: Key: StrokeColour, DisplayName: Stroke Colour, FieldType: Color, DefaultValue: 0xFFFFFFFF, Description: Stroke colour
#DesignerProperty: Key: StrokeWidth, DisplayName: Stroke Width, FieldType: Int, DefaultValue: 10, Description: Thickness of arc lines
#DesignerProperty: Key: Duration, DisplayName: Duration of spin, FieldType: Int, DefaultValue: 1000, Description: Milliseconds to spin 360 degrees
Sub Class_Globals
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Private mBase As B4XView 'ignore
Private xui As XUI 'ignore
Private cvs As B4XCanvas
Private cx, cy, radius As Float
Private stroke As Float
Private strokeClr As Int
Private durationFromZeroTo360 As Int
Private ani As Animation
End Sub
Public Sub Initialize (Callback As Object, EventName As String)
mEventName = EventName
mCallBack = Callback
End Sub
'Base type must be Object
Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
mBase = Base
mBase.SetLayoutAnimated(0, mBase.Left, mBase.Top, Min(mBase.Width, mBase.Height), Min(mBase.Width, mBase.Height))
strokeClr = xui.PaintOrColorToColor(Props.Get("StrokeColour"))
stroke = DipToCurrent(Props.Get("StrokeWidth"))
durationFromZeroTo360 = Props.Get("Duration")
cx = mBase.Width / 2
cy = mBase.Height / 2
radius = cx - 10dip
ani.InitializeRotateCenter("", 0, 360, mBase)
ani.Duration = durationFromZeroTo360
ani.RepeatCount = -1
ani.RepeatMode = ani.REPEAT_RESTART
cvs.Initialize(mBase)
DrawArcs
ani.Start(mBase)
End Sub
Private Sub Base_Resize (Width As Double, Height As Double)
cx = Width / 4
cy = Height / 4
radius = cx - 10dip
mBase.SetLayoutAnimated(0, mBase.Left, mBase.Top, Min(Width,Height), Min(Width, Height))
cvs.Resize(Width, Height)
DrawArcs
ani.Start(mBase)
End Sub
'property getters and setters
Public Sub setEnabled(Enabled As Boolean)
mBase.Enabled = Enabled
End Sub
Public Sub getEnabled As Boolean
Return mBase.Enabled
End Sub
Public Sub setVisible(Visible As Boolean)
mBase.Visible = Visible
End Sub
Public Sub getVisible As Boolean
Return mBase.Visible
End Sub
Public Sub setTag(Tag As String)
mBase.Tag = Tag
End Sub
Public Sub getTag As String
Return mBase.Tag
End Sub
Private Sub DrawArcs
cx = mBase.Width / 2
cy = mBase.Height / 2
cvs.ClearRect(cvs.TargetRect)
Dim p1, p2 As B4XPath
p1.InitializeArc(cx, cy, radius + stroke + 1dip, 35, 110)
cvs.ClipPath(p1)
cvs.DrawCircle(cx, cy, radius - 0.5dip, strokeClr, False, stroke + 1dip)
cvs.RemoveClip
p2.InitializeArc(cx, cy, radius + stroke + 1dip, 215, 110)
cvs.ClipPath(p2)
cvs.DrawCircle(cx, cy, radius - 0.5dip, strokeClr, False, stroke + 1dip)
cvs.RemoveClip
cvs.Invalidate
End Sub