BeeriaApps
New Member
Hello all.
I've created UI app which runs some java code (in inline java section). All code (both b4j and java) is in 'main' section.
The problem is, when java method is triggered, UI freezes and is not responsive (until java part is finished). Application works as expected, just doesn't look "professional" because of frozen UI while java is executed.
How to avoid such situation?
Sub which triggers inline java -->
inline java part
found similar topic -->
https://www.b4x.com/android/forum/threads/resumable-subs-with-java-inline-code.80035/#post-506764
but unfortunately my java knowledge is VERY limited and have no idea how to deal with such a problem.
Any help highly appreciated.
I've created UI app which runs some java code (in inline java section). All code (both b4j and java) is in 'main' section.
The problem is, when java method is triggered, UI freezes and is not responsive (until java part is finished). Application works as expected, just doesn't look "professional" because of frozen UI while java is executed.
How to avoid such situation?
Sub which triggers inline java -->
B4X:
Sub btnOpenFW_Click
btnOpenFW.Enabled = False
TextAreaMylogs.Text = "Start..."
Sleep(10)'time to refresh UI before java is executed
Dim myLogin As String = txtLogin.Text
Dim myPass As String = txtPassword.Text
If isPassShown = 0 Then myPass = txtPassword.Text Else myPass = txtPasswordShown.Text
Dim driverLocation As String
driverLocation = ((GetSystemProperty("user.home", "").Replace("\", "/")) & "/chromedriver/chromedriver.exe")
NativeMe = Me
Dim a As String = NativeMe.RunMethod("FWOpen", Array(myLogin, myPass, driverLocation))
btnOpenFW.Enabled = True
TextAreaMylogs.Text = TextAreaMylogs.Text & CRLF & a
End Sub
Java:
#If JAVA
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
public static String FWOpen(String myLogin, String myPass, String driverLocation) {
System.setProperty("webdriver.chrome.driver", driverLocation);
ChromeDriver driver = new ChromeDriver();
driver.manage().window().setPosition(new org.openqa.selenium.Point(0, 4000));
driver.manage().window().setSize(new org.openqa.selenium.Dimension(1920, 1200));
WebDriverWait wait = new WebDriverWait(driver, 10);
//the rest of the code are just interactions with the browser
}
#End If
https://www.b4x.com/android/forum/threads/resumable-subs-with-java-inline-code.80035/#post-506764
but unfortunately my java knowledge is VERY limited and have no idea how to deal with such a problem.
Any help highly appreciated.