diff --git a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java index f09f06aa34..fff1a99798 100755 --- a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java +++ b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java @@ -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() diff --git a/examples/androidlcl/mainform.lfm b/examples/androidlcl/mainform.lfm index 471a7b57ca..87ddc01797 100644 --- a/examples/androidlcl/mainform.lfm +++ b/examples/androidlcl/mainform.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 313 + Left = 326 Height = 251 - Top = 186 + Top = 166 Width = 220 Caption = 'Form1' ClientHeight = 251 diff --git a/lcl/interfaces/customdrawn/customdrawnobject_android.inc b/lcl/interfaces/customdrawn/customdrawnobject_android.inc index 573555480e..ab94f08a10 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_android.inc @@ -807,6 +807,7 @@ function TCDWidgetSet.DestroyTimer(TimerHandle: THandle) : boolean; var lTimer: TCDTimer; begin + DebugLn('[TCDWidgetSet.DestroyTimer]'); Result := False; lTimer := TCDTimer(TimerHandle); diff --git a/lcl/interfaces/customdrawn/customdrawnwsforms_android.inc b/lcl/interfaces/customdrawn/customdrawnwsforms_android.inc index 9b239faf8c..e4d46405d2 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsforms_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnwsforms_android.inc @@ -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