Animation Library - problem

ssg

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Button click is not being triggered when animation is used.

Try the sample code attached, with the following steps:

1 - click button on main activity.
2 - second activity is loaded, so far so good.
3 - click the back button (hardware button)
4 - main activity is shown, as expected, and the animation continues
5 - now click the button again on main, nothing happens, click a few times and it works.

I have attached a sample code that is causing this issue.

Please help!

Thank you!

Cheers!
 

Attachments

  • animprob.zip
    5.4 KB · Views: 246

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see this issue too. The button event is raised (add a Log message and you will see) however the Intent sent is ignored. It seems to be a bug in Android as the intent starting the activity seems to be correct.

A workaround is to use a timer to start the activity.
This code works fine:
B4X:
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim tmr 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.
    Dim pnl As Panel
    Dim anim As Animation
    Dim b As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        tmr.Initialize("tmr", 10)
    End If
    pnl.Initialize("")
    Activity.AddView(pnl, 30dip, 30dip, 20%x, 20%x)
    pnl.Color = Colors.Blue
    anim.InitializeRotate("anim", 0, 359)
    anim.Duration = 2000
    anim.RepeatCount = -1
    anim.RepeatMode = anim.REPEAT_REVERSE
    
    b.Initialize("b")
    Activity.AddView(b, 30dip, 100dip, 100dip, 50dip)
    b.Text = "click me"

End Sub

Sub b_Click
    Log("b_click")
    anim.Stop(pnl)
    tmr.Enabled = True
End Sub
Sub tmr_Tick
    StartActivity(activity2)
End Sub
Sub Activity_Resume
    anim.Start(pnl)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    tmr.Enabled = False
    anim.Stop(pnl)
End Sub
 
Upvote 0
Top