Hi,
I am using the WheelView library V1.1. It does a nice job, but I have a couple of problems with it.
If I run the code without breakpoints the wheels are not set. If I run in debug mode and stop on line 58 and step through the wheels move to the correct values. I tried putting sleeps in various places, but this did not provide a fix. I also tried setting the wheel. Delay to 1 ms, but this did not have any effect.
The log output without breakpoints then with breakpoints is shown below:
I think that the animation should be able to be turned on and off for the SetToValue
2. SetToValue Initiates a wheel tick event.
Setting the wheel value using SetToValue initiates a wheel_tick event as if the user had moved a wheel and it had settled on a value. This is unnecessary behavior, as if the value of a wheel is set programmatically if another variable needs this value then it doesn't need to get it from the wheel this variable can be set programmatically also. I have a feeling that it's this behavior that is causing the problem of the wheels failing to respond to the SetToValue function.
The same problem occurs with other views like tabs. Adding half a dozen tabs programmatically calls the TabStrip1_PageSelected event function each time. This can be useful some of the time, but at other times, it is a pain. Why can't events be disabled/enabled programmatically? Is this possible or does the underlying Java engine prevent this?
An enhancement to the Wheel library would be to make the parameters such as Delay, Color, etc read and write instead of just write only. This read restriction seem to pop up a lot with B4X objects. Is there a reason for this or is it just that the programmer didn't put a get value method in?
Best regards
Rob
I am using the WheelView library V1.1. It does a nice job, but I have a couple of problems with it.
- Wheels aren't changeing when set programatically with whee.SetToValue function.
I set a wheel programmatically with the following code:
B4X:
Type tblExercise_t( _
exID As Int, _
wgID As Int, _
wgDescription As String, _
weightKg As Double, _
repetitions As Int, _
noOfSets As Int, _
comments As String)
Private tblExercise As tblExercise_t
'======================================================================================================
Sub init_wheels(left As Int, right As Int,height As Int,bottom As Int)
Dim whlList As List
whlList.Initialize
'Get the wheel lists from the database and use these to initialize the wheels
whlList = dbRT.getWheelList("tblWeightsList", "weightKG", 0, "Weight ", " kg" )
whlWeight.Initialize1(height, whlList, True, "whlWeight")
whlList = dbRT.getWheelList("tblWeightsList", "weightKG", 5, "Sets ", "")
whlNoSets.Initialize1(height, whlList, True, "whlNoSets") ' using lst as list
whlList = dbRT.getWheelList("tblWeightsList", "weightKG", 0, "Rps ", "" )
whlReps.Initialize1(height, whlList, True, "whlReps") ' using val as array
whlNoSets.TextSize = 13
whlReps.TextSize = 13
whlWeight.TextSize = 13
' Left Top Width Height
Activity.AddView(whlReps, left, 100%y - height * 3 - bottom, (100%x - left - right) / 3, height * 3)
Activity.AddView(whlNoSets, whlReps.Width + left, 100%y - height * 3 - bottom, (100%x - left - right) / 3, height * 3)
Activity.AddView(whlWeight,whlReps.Width + whlReps.Width + left, 100%y - height * 3 - bottom, (100%x - left - right) / 3, height * 3)
overlay.Initialize("")
overlay.SetBackgroundImage(LoadBitmap(File.DirAssets,"cover.png"))
Activity.AddView(overlay, left, 100%y - height * 3 - bottom, 100%x - left - right, height * 3)
Sleep(0)
End Sub
Private whlNoSets As WheelView
Private whlReps As WheelView
Private whlWeight As WheelView
setWheelsToTarget
....
'======================================================================================================
Sub setWheelsToTarget()
tblExercise.weightKg = 5
tblExercise.repetitions = 8
tblExercise.noOfSets = 3
whlWeight.SetToValue(tblExercise.weightKg - 1)
Log("Weight Wheel Index = " & tblExercise.weightKg & " Weight Wheel Text: " & whlWeight.ReadWheel)
whlReps.SetToValue(tblExercise.repetitions - 1)
Log("Reps Wheel Index = " & tblExercise.repetitions & " Reps Wheel Text: " & whlReps.ReadWheel)
whlNoSets.SetToValue(tblExercise.noOfSets - 1)
Log("No of Sets Wheel Index = " & tblExercise.noOfSets & " No Sets Wheel Text: " & whlNoSets.ReadWheel)
End Sub
'======================================================================================================
public Sub getWheelList(tblName As String, field As String, Limit As Int, prefix As String, suffix As String) As List
Dim qryStr As String = "SELECT " & field & " FROM " & tblName & " ORDER BY " & field & " ASC"
Return DBUtils.ExecuteWheel(sqlDB, qryStr, Null, Limit, prefix, suffix)
End Sub
If I run the code without breakpoints the wheels are not set. If I run in debug mode and stop on line 58 and step through the wheels move to the correct values. I tried putting sleeps in various places, but this did not provide a fix. I also tried setting the wheel. Delay to 1 ms, but this did not have any effect.
The log output without breakpoints then with breakpoints is shown below:
Log Output No breakpoints then with breakpoints:
No Breakpoints
'--------------------------------------------------------
Weight Wheel Index = 5 Weight Wheel Text: Weight 1 kg
Reps Wheel Index = 8 Reps Wheel Text: Rps 1
No of Sets Wheel Index = 3 No Sets Wheel Text: Sets 1
'--------------------------------------------------------
With Breakpoint - single stepping
'--------------------------------------------------------
Weight Wheel Index = 5 Weight Wheel Text: Weight 5 kg
Reps Wheel Index = 8 Reps Wheel Text: Rps 8
No of Sets Wheel Index = 3 No Sets Wheel Text: Sets 3
'--------------------------------------------------------
I think that the animation should be able to be turned on and off for the SetToValue
2. SetToValue Initiates a wheel tick event.
Setting the wheel value using SetToValue initiates a wheel_tick event as if the user had moved a wheel and it had settled on a value. This is unnecessary behavior, as if the value of a wheel is set programmatically if another variable needs this value then it doesn't need to get it from the wheel this variable can be set programmatically also. I have a feeling that it's this behavior that is causing the problem of the wheels failing to respond to the SetToValue function.
The same problem occurs with other views like tabs. Adding half a dozen tabs programmatically calls the TabStrip1_PageSelected event function each time. This can be useful some of the time, but at other times, it is a pain. Why can't events be disabled/enabled programmatically? Is this possible or does the underlying Java engine prevent this?
An enhancement to the Wheel library would be to make the parameters such as Delay, Color, etc read and write instead of just write only. This read restriction seem to pop up a lot with B4X objects. Is there a reason for this or is it just that the programmer didn't put a get value method in?
Best regards
Rob