mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 01:29:28 +01:00
Android: Fixes screen sizing and attempts to improve timer destruction
git-svn-id: trunk@34281 -
This commit is contained in:
parent
001954f566
commit
454c19a3d7
@ -34,13 +34,16 @@ public class LCLActivity extends Activity
|
|||||||
//Log.i("lclapp", "onDraw started");
|
//Log.i("lclapp", "onDraw started");
|
||||||
int lWidth = getWidth();
|
int lWidth = getWidth();
|
||||||
int lHeight = getHeight();
|
int lHeight = getHeight();
|
||||||
|
int oldlclformwidth = lclformwidth;
|
||||||
// Check if we rotated in the draw event, OnConfigurationChanged can't return the new form width =(
|
|
||||||
// see http://stackoverflow.com/questions/2524683/how-to-get-new-width-height-of-root-layout-in-onconfigurationchanged
|
|
||||||
if (lWidth != lclformwidth) LCLOnConfigurationChanged(lclxdpi, lWidth); // we send xdpi because thats what the LCL uses for Screen.PixelsPerInch
|
|
||||||
|
|
||||||
lclformwidth = lWidth;
|
lclformwidth = lWidth;
|
||||||
lclformheight = lHeight;
|
lclformheight = lHeight;
|
||||||
|
lclscreenwidth = lclformwidth;
|
||||||
|
lclscreenheight = lclformheight;
|
||||||
|
|
||||||
|
// Check if we rotated in the draw event, OnConfigurationChanged can't return the new form width =(
|
||||||
|
// see http://stackoverflow.com/questions/2524683/how-to-get-new-width-height-of-root-layout-in-onconfigurationchanged
|
||||||
|
if (lWidth != oldlclformwidth) LCLOnConfigurationChanged(lclxdpi, lWidth); // we send xdpi because thats what the LCL uses for Screen.PixelsPerInch
|
||||||
|
|
||||||
//Log.v("lclproject", "LCLSurface.onDraw width=" + Integer.toString(lWidth)
|
//Log.v("lclproject", "LCLSurface.onDraw width=" + Integer.toString(lWidth)
|
||||||
// + " height=" + Integer.toString(lHeight));
|
// + " height=" + Integer.toString(lHeight));
|
||||||
@ -251,19 +254,23 @@ public class LCLActivity extends Activity
|
|||||||
|
|
||||||
private Handler LocalHandler = new Handler();
|
private Handler LocalHandler = new Handler();
|
||||||
|
|
||||||
|
private class LCLRunnable implements Runnable
|
||||||
|
{
|
||||||
|
public boolean Destroyed = false;
|
||||||
|
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
int eventResult = LCLOnTimer(this);
|
||||||
|
if (((eventResult | 1) != 0) && (lclsurface != null)) lclsurface.postInvalidate();
|
||||||
|
if (this.Destroyed == false) LocalHandler.postDelayed(this, lcltimerinterval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// input: int lcltimerinterval in milliseconds
|
// input: int lcltimerinterval in milliseconds
|
||||||
// output: Runnable lcltimerid
|
// output: Runnable lcltimerid
|
||||||
public void LCLDoCreateTimer()
|
public void LCLDoCreateTimer()
|
||||||
{
|
{
|
||||||
lcltimerid = new Runnable()
|
lcltimerid = new LCLRunnable();
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
int eventResult = LCLOnTimer(this);
|
|
||||||
if (((eventResult | 1) != 0) && (lclsurface != null)) lclsurface.postInvalidate();
|
|
||||||
LocalHandler.postDelayed(this, lcltimerinterval);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LocalHandler.removeCallbacks(lcltimerid);
|
LocalHandler.removeCallbacks(lcltimerid);
|
||||||
LocalHandler.postDelayed(lcltimerid, lcltimerinterval);
|
LocalHandler.postDelayed(lcltimerid, lcltimerinterval);
|
||||||
@ -273,6 +280,7 @@ public class LCLActivity extends Activity
|
|||||||
public void LCLDoDestroyTimer()
|
public void LCLDoDestroyTimer()
|
||||||
{
|
{
|
||||||
LocalHandler.removeCallbacks(lcltimerid);
|
LocalHandler.removeCallbacks(lcltimerid);
|
||||||
|
((LCLRunnable) lcltimerid).Destroyed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public void LCLDoHideVirtualKeyboard()
|
public void LCLDoHideVirtualKeyboard()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 313
|
Left = 326
|
||||||
Height = 251
|
Height = 251
|
||||||
Top = 186
|
Top = 166
|
||||||
Width = 220
|
Width = 220
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 251
|
ClientHeight = 251
|
||||||
|
|||||||
@ -807,6 +807,7 @@ function TCDWidgetSet.DestroyTimer(TimerHandle: THandle) : boolean;
|
|||||||
var
|
var
|
||||||
lTimer: TCDTimer;
|
lTimer: TCDTimer;
|
||||||
begin
|
begin
|
||||||
|
DebugLn('[TCDWidgetSet.DestroyTimer]');
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
lTimer := TCDTimer(TimerHandle);
|
lTimer := TCDTimer(TimerHandle);
|
||||||
|
|||||||
@ -91,6 +91,7 @@ begin
|
|||||||
lForm.LCLForm.AutoAdjustLayout(lapAutoAdjustWithoutHorizontalScrolling,
|
lForm.LCLForm.AutoAdjustLayout(lapAutoAdjustWithoutHorizontalScrolling,
|
||||||
lForm.LCLForm.DesignTimeDPI,
|
lForm.LCLForm.DesignTimeDPI,
|
||||||
Screen.PixelsPerInch, lForm.LCLForm.Width, Screen.Width);
|
Screen.PixelsPerInch, lForm.LCLForm.Width, Screen.Width);
|
||||||
|
LCLIntf.InvalidateRect(HWND(lForm), nil, False);
|
||||||
// if necessary adjust the form coordinates
|
// if necessary adjust the form coordinates
|
||||||
if not (lForm.LCLForm.BorderStyle in [bsDialog, bsNone]) then
|
if not (lForm.LCLForm.BorderStyle in [bsDialog, bsNone]) then
|
||||||
begin
|
begin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user