Private Sub StartScrolling (p As B4XView, OriginalWidth As Float)
taskIndex = taskIndex + 1
Dim myIndex As Int = taskIndex
Dim duration As Int = p.Width / WidthPerSecond * 1000
Do While True
'this loop causes higher cpu load when app is minimized!!!???????
'not minimized is OK!!!
'so, check if minimized and then sleep:
Dim st As JavaObject=Main.yourmainform
Dim sta As JavaObject=st.GetFieldJO("stage")
If sta.RunMethod("isIconified",Null)=True Then
Sleep(2000)
If myIndex <> taskIndex Then Return
Else
p.SetLayoutAnimated(duration, -(p.Width - OriginalWidth), p.Top, p.Width, p.Height)
Sleep(duration)
If myIndex <> taskIndex Then Return
Sleep(800)
p.SetLayoutAnimated(0, 0, p.Top, p.Width, p.Height)
If myIndex <> taskIndex Then Return
End If
Loop
End Sub