Android: Fixes screen sizing and attempts to improve timer destruction

git-svn-id: trunk@34281 -
This commit is contained in:
sekelsenmat 2011-12-19 14:31:09 +00:00
parent 001954f566
commit 454c19a3d7
4 changed files with 25 additions and 15 deletions

View File

@ -34,13 +34,16 @@ public class LCLActivity extends Activity
//Log.i("lclapp", "onDraw started");
int lWidth = getWidth();
int lHeight = getHeight();
// 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
int oldlclformwidth = lclformwidth;
lclformwidth = lWidth;
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)
// + " height=" + Integer.toString(lHeight));
@ -251,19 +254,23 @@ public class LCLActivity extends Activity
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
// output: Runnable lcltimerid
public void LCLDoCreateTimer()
{
lcltimerid = new Runnable()
{
public void run()
{
int eventResult = LCLOnTimer(this);
if (((eventResult | 1) != 0) && (lclsurface != null)) lclsurface.postInvalidate();
LocalHandler.postDelayed(this, lcltimerinterval);
}
};
lcltimerid = new LCLRunnable();
LocalHandler.removeCallbacks(lcltimerid);
LocalHandler.postDelayed(lcltimerid, lcltimerinterval);
@ -273,6 +280,7 @@ public class LCLActivity extends Activity
public void LCLDoDestroyTimer()
{
LocalHandler.removeCallbacks(lcltimerid);
((LCLRunnable) lcltimerid).Destroyed = true;
};
public void LCLDoHideVirtualKeyboard()

View File

@ -1,7 +1,7 @@
object Form1: TForm1
Left = 313
Left = 326
Height = 251
Top = 186
Top = 166
Width = 220
Caption = 'Form1'
ClientHeight = 251

View File

@ -807,6 +807,7 @@ function TCDWidgetSet.DestroyTimer(TimerHandle: THandle) : boolean;
var
lTimer: TCDTimer;
begin
DebugLn('[TCDWidgetSet.DestroyTimer]');
Result := False;
lTimer := TCDTimer(TimerHandle);

View File

@ -91,6 +91,7 @@ begin
lForm.LCLForm.AutoAdjustLayout(lapAutoAdjustWithoutHorizontalScrolling,
lForm.LCLForm.DesignTimeDPI,
Screen.PixelsPerInch, lForm.LCLForm.Width, Screen.Width);
LCLIntf.InvalidateRect(HWND(lForm), nil, False);
// if necessary adjust the form coordinates
if not (lForm.LCLForm.BorderStyle in [bsDialog, bsNone]) then
begin