I need to update the display percentage of an image view, which has PDF rendered into images.
When I am zooming in, it displays the thumbnail and then renders the PDF into a high-fidelity one, which costs time. How to avoid the unnecessary rendering when zooming? I think it is called debounce.
Here is the simulated demo code:
When I am zooming in, it displays the thumbnail and then renders the PDF into a high-fidelity one, which costs time. How to avoid the unnecessary rendering when zooming? I think it is called debounce.
Here is the simulated demo code:
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private Spinner1 As Spinner
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Dim jo As JavaObject = Spinner1
Dim e As Object = jo.CreateEventFromUI("javafx.event.EventHandler", "scroll", Null)
jo.RunMethod("setOnScroll", Array(e))
End Sub
Sub Button1_Click
xui.MsgboxAsync("Hello World!", "B4X")
End Sub
Private Sub Spinner1_ValueChanged (Value As Object)
HeavyJob
End Sub
Private Sub HeavyJob
Log("HeavyJob")
Sleep(5000)
Log("HeavyJob done")
End Sub
Sub Scroll_Event (MethodName As String, Args() As Object) As Object
Dim scrollevent As JavaObject = Args(0)
Dim DeltaY As Int=scrollevent.RunMethod("getDeltaY", Null)
If DeltaY>0 Then
Spinner1.Value=Spinner1.Value+5
Else
Spinner1.Value=Spinner1.Value-5
End If
Return Null
End Sub