Progressbar Not Working with Latest Android Player (9.0)
Progressbar Not Working with Latest Android Player (9.0)
The RapaGUI Progressbar Class doesn't seem to work with the newest Hollywood Player for Android.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Progressbar Not Working with Latest Android Player (9.0)
Can't reproduce this here. The progressbar in the demo sample that comes with RapaGUI works fine here. Have you got an MCVE?
Re: Progressbar Not Working with Latest Android Player (9.0)
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateApp([[
<application id="app">
<window id="win">
<vgroup>
<text>Progress Test</text>
</vgroup>
</window>
</application>
]])
moai.CreateDialog([[
<dialog id="prgdlg" title="Loading..." width="300" closegadget="false">
<vgroup>
<progressbar id="prgbar"/>
</vgroup>
</dialog>
]])
Function p_DialogFunc(msg)
For Local k = 0 To 100
moai.Set("prgbar", "level", k)
CheckEvent()
If abortpressed = True Then Return(False, False)
Wait(2)
Next
Return(True, False)
EndFunction
moai.DoMethod("prgdlg", "showmodal", p_DialogFunc)
Repeat
WaitEvent
Forever
It works fine when I run it on Amiga OS4, but no progress is shown when running the applet on the latest Hollywood player for Android.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Progressbar Not Working with Latest Android Player (9.0)
Ok, that's not a bug. It's caused by the following API change in RapaGUI 2.0:
Here's the latest Dialogs example from the RapaGUI 2.0 master:
Code: Select all
- Change: Dialog.ShowModal() no longer supports dialog functions; if you want to open a dialog that
doesn't block your script, you now have to set Window.Open to TRUE for the dialog (and possibly
Application.Sleep to TRUE too) and then you can implement the dialog's actual behaviour by repeatedly
calling a management function either using SetTimeout() or Hollywood 9.0's new RunCallback() function;
take a look at the updated Dialogs example for a reference implementation
Code: Select all
/****************************************************************
** **
** Name: Dialogs **
** Author: Andreas Falkenhahn **
** Version: 1.2 **
** Date: 07.09.19 **
** Interpreter: Hollywood 9.0 **
** Licence: Sample program **
** Function: Demonstrates how to use dialogs in RapaGUI **
** **
** History: **
** **
** 1.2: (07.09.19) **
** **
** - adapted for RapaGUI 2.0 **
** **
** 1.1: (11.07.18) **
** **
** - sets dialog button hints now for Android **
** **
** 1.0: (06.05.16) **
** **
** - initial release **
** **
****************************************************************/
/*
** Make sure we have at least Hollywood 9.0!
*/
@VERSION 9,0
/*
** Enable DPI-awareness so that our GUI looks sharp even on high DPI monitors
*/
@OPTIONS {DPIAware = True}
/*
** This script requires the RapaGUI plugin
*/
@REQUIRE "RapaGUI"
/*
** Information about this app
*/
@APPTITLE "Dialogs"
@APPVERSION "$VER: Dialogs 1.0 (06.05.16)"
@APPCOPYRIGHT "(C) 2016 Andreas Falkenhahn"
@APPAUTHOR "Andreas Falkenhahn"
@APPDESCRIPTION "Demonstrates how to use dialogs in RapaGUI"
/*
** Our XML GUI definition
*/
@FILE 1, "Dialogs.xml"
@FILE 2, "Edit.xml"
@FILE 3, "Progress.xml"
/*
** Create our dialog
*/
Function p_CreateDialog()
Seek(2, 0)
; conveniently create new dialog from an external *.xml and use our main window as the parent
; see the RapaGUI documentation to find out why you should create dialogs only temporarily
moai.CreateDialog(ReadString(2), "win")
EndFunction
/*
** Open our dialog
*/
Function p_OpenDialog()
; start modal dialog loop
moai.DoMethod("dlg", "showmodal")
EndFunction
/*
** Close our dialog
*/
Function p_CloseDialog()
; this will automatically destroy the dialog
moai.DoMethod("dlg", "endmodal", 0)
EndFunction
/*
** Fill dialog fields with contents from listview
*/
Function p_Edit()
Local state, lastname$, firstname$, street$, city$, zip$, country$ = moai.DoMethod("lv", "getentry", "active")
editmode = True
p_CreateDialog()
moai.Set("lastname", "text", lastname$)
moai.Set("firstname", "text", firstname$)
moai.Set("street", "text", street$)
moai.Set("city", "text", city$)
moai.Set("zip", "text", zip$)
moai.Set("country", "text", country$)
p_OpenDialog()
EndFunction
/*
** Update button states depending on currently active entry
*/
Function p_RefreshButtons(active)
moai.Set("rem", "disabled", active = -1)
moai.Set("edit", "disabled", active = -1)
moai.Set("mvup", "disabled", (active <= 0))
moai.Set("mvdown", "disabled", (active = -1) Or (active = moai.Get("lv", "entries") - 1))
EndFunction
/*
** Helper function to show/hide a dialog
*/
Function p_ShowHideDialog(dlg$, flag)
If flag
moai.Set("app", "sleep", True)
moai.Set(dlg$, "open", True)
Else
moai.Set(dlg$, "open", False)
moai.FreeDialog(dlg$)
moai.Set("app", "sleep", False)
EndIf
EndFunction
/*
** Handler function for our progress bar dialog
*/
Function p_DialogFunc(msg)
; update progress bar
moai.Set("prgbar", "level", msg.userdata)
If abortpressed = True ; abort button pressed?
p_ShowHideDialog("dlg2", False)
moai.Request("", "Dialog aborted!", "OK", "error")
ElseIf msg.userdata = 100 ; progress bar completed?
p_ShowHideDialog("dlg2", False)
moai.Request("", "Dialog completed!", "OK")
Else
; not finished yet? call us again!
RunCallback(p_DialogFunc, msg.userdata + 1)
; this is only to slow things down so that we're simulating
; a real progress bar; in a real app, there's no need to
; insert a delay
Wait(20, #MILLISECONDS)
EndIf
EndFunction
/*
** Just a test for function-based dialogs
*/
Function p_TestProgressbarDialog()
abortpressed = False
Seek(3, 0)
; conveniently create new dialog from an external *.xml and use our main window as the parent
; see the RapaGUI documentation to find out why you should create dialogs only temporarily
moai.CreateDialog(ReadString(3), "win")
; show dialog
p_ShowHideDialog("dlg2", True)
; do some work and then return
p_DialogFunc({userdata = 0})
EndFunction
/*
** Handles all incoming events
*/
Function p_EventFunc(msg)
Switch msg.action
Case "RapaGUI":
Switch msg.attribute
Case "Active":
p_RefreshButtons(msg.triggervalue)
Case "Selected":
Switch msg.id
Case "mn_prgbar":
p_TestProgressbarDialog()
Case "mn_exit":
End
EndSwitch
Case "Pressed":
Switch msg.id
Case "add"
editmode = False
p_CreateDialog()
p_OpenDialog()
Case "rem"
moai.DoMethod("lv", "remove", "active")
Case "edit"
p_Edit()
Case "mvup"
Local c = moai.Get("lv", "active")
moai.DoMethod("lv", "exchange", "active", "previous")
moai.Set("lv", "active", c - 1)
Case "mvdown"
Local c = moai.Get("lv", "active")
moai.DoMethod("lv", "exchange", "active", "next")
moai.Set("lv", "active", c + 1)
Case "ok"
Local lastname$ = moai.Get("lastname", "text")
Local firstname$ = moai.Get("firstname", "text")
Local street$ = moai.Get("street", "text")
Local city$ = moai.Get("city", "text")
Local zip$ = moai.Get("zip", "text")
Local country$ = moai.Get("country", "text")
If (lastname$ = "") Or (firstname$ = "")
moai.Request("", "Please fill out all required fields!", "OK", "error")
Return
EndIf
p_CloseDialog()
If editmode = False
pos = moai.DoMethod("lv", "insert", "bottom", "false", lastname$, firstname$, street$, city$, zip$, country$)
Else
moai.DoMethod("lv", "rename", "active", "false", lastname$, firstname$, street$, city$, zip$, country$)
EndIf
Local active = moai.Get("lv", "active")
If active <> -1 Then p_RefreshButtons(active)
Case "cancel"
p_CloseDialog()
Case "stop"
abortpressed = True
EndSwitch
EndSwitch
EndSwitch
EndFunction
; dynamically create GUI from an external *.xml file definition
moai.CreateApp(ReadString(1))
; listen to these events!
InstallEventHandler({RapaGUI = p_EventFunc})
; main loop!
Repeat
WaitEvent
Forever
Re: Progressbar Not Working with Latest Android Player (9.0)
Very good.
Thanks!
Thanks!