I’m working on a Firemonkey application in Delphi Tokyo and decided to add a loader screen that does some animation. I have a form with a list animation that is run within one thread, and then my calls to the datasnap server runs within another thread. I’m doing it like this because I couldn’t get the animation to work if both calls wasn’t within a thread.
Now running this on the windows version works fine. Running it on both my Huawei phone and another samsung tablet works 70% of the time. The other 30% of the time it freezes and I have to kill the app. When the datasnap load is done the loader form is supposed to be freed and closed and the main panels opacity is set to 1 and I enable the panel again. I’m not sure 100% if the app freezes and if the code is not run successfully thats supposed to enable the panel again. I was able to debug it one time while not working which produced an out of memory error, but I’m unable to recreate the issue while debugging on the phone.
The idea was that when the logging button is pressed a loader screen shows some animation while the data is retrieved and then hides it again. Am I doing something wrong in the below code?
fThread := TTask.Create
LoDataset := fmxDataModule.ServerMethods.GetLoginDetails(edtEmail.Text, edtPassword.Text);
except on E:Exception do
ShowMessage(‘The system could not log you in. Error Details: ‘+slinebreak+slinebreak+E.Message+slinebreak+slinebreak+’Please try again.’);
if fmxDataModule.LoggedInUser.CompanyID.Value > 0 then
Toolbarheader.Visible := True;
lblLoginInfo.Visible := false;
lblWelcome.Text := ‘Welcome ‘ + fmxDataModule.LoggedInUser.FirstName.Value + ‘, ‘ + fmxDataModule.LoggedInUser.LastName.Value;
pnlButtons.Visible := True;
fLoggedIn := True;
lblLoginInfo.Visible := True;
lblLoginInfo.Text := ‘User does not exist, or login details invalid’;
Here is the code for ShowLoader:
if Assigned(fLoader) then
fLoader := TfrmLoader.Create(Self);
floader.Parent := Self;
fLoader.Left := Self.Left + (Self.Width div 2) – (fLoader.Width div 2);
fLoader.Top := Self.Top + (Self.Height div 2) – (fLoader.Height div 2);
pnlMain.Enabled := false;
pnlMain.Opacity := 0.4;
Hiding the loader:
pnlMain.Enabled := True;
pnlMain.Opacity := 1;
fLoader.Visible := False;
Am I missing something in the code above?
Another question is why does my form not open in the middle of the screen? I’ve tried different things, setting the position in the form properties, and manually calculating it. It always opens up top left corner on the device, but works on windows.