mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-02 03:09:32 +02:00
android: Adds the bindings side of the timer support
git-svn-id: trunk@31735 -
This commit is contained in:
parent
07bb9fee4c
commit
0225972c3c
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -5206,6 +5206,7 @@ lcl/interfaces/android/androidint.pas svneol=native#text/pascal
|
||||
lcl/interfaces/android/androidobject.inc svneol=native#text/pascal
|
||||
lcl/interfaces/android/androidpipescomm.pas svneol=native#text/pascal
|
||||
lcl/interfaces/android/androidprivate.pas svneol=native#text/pascal
|
||||
lcl/interfaces/android/androidtimer.pas svneol=native#text/pascal
|
||||
lcl/interfaces/android/androidwsfactory.pas svneol=native#text/pascal
|
||||
lcl/interfaces/android/interfaces.pp svneol=native#text/plain
|
||||
lcl/interfaces/android/javalang.pas svneol=native#text/pascal
|
||||
|
@ -75,7 +75,7 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses android_all, androidapp, javalang;
|
||||
uses android_all, androidapp, androidtimer, javalang;
|
||||
|
||||
var
|
||||
Str: string;
|
||||
@ -159,8 +159,8 @@ begin
|
||||
amkTimer: // A Timer Callback
|
||||
begin
|
||||
lPascalPointer := ReadInt();
|
||||
{ TAndroidTimer(lPascalPointer).callOnTimerListener();
|
||||
vAndroidPipesComm.SendMessage(amkTimer, amkTimer_Callback_Finished);}
|
||||
TAndroidTimer(lPascalPointer).callOnTimerListener();
|
||||
vAndroidPipesComm.SendMessage(amkTimer, amkTimer_Callback_Finished);
|
||||
end;
|
||||
end;
|
||||
// dataString1 := 'Pascal log: ' + IntToStr(lByte) + LineEnding;
|
||||
|
71
lcl/interfaces/android/androidtimer.pas
Normal file
71
lcl/interfaces/android/androidtimer.pas
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
Android4Pascal - Android API Bindings for Pascal
|
||||
|
||||
Author: Felipe Monteiro de Carvalho - 2011
|
||||
License: modified LGPL (the same as the Free Pascal RTL, Lazarus LCL)
|
||||
}
|
||||
unit androidtimer;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, javalang;
|
||||
|
||||
type
|
||||
|
||||
{ TAndroidTimer }
|
||||
|
||||
TAndroidTimer = class(TJavaObject)
|
||||
OnTimer: TNotifyEvent;
|
||||
constructor Create;
|
||||
procedure postDelayed(ADelay: Integer);
|
||||
procedure removeCallbacks();
|
||||
procedure callOnTimerListener();
|
||||
end;
|
||||
|
||||
const
|
||||
amkTimer_New_Runnable = $0000;
|
||||
amkTimer_postDelayed = $0001;
|
||||
amkTimer_removeCallbacks = $0002;
|
||||
amkTimer_Callback_Finished = $0EEE0000;
|
||||
|
||||
implementation
|
||||
|
||||
uses androidpipescomm;
|
||||
|
||||
{ TAndroidTimer }
|
||||
|
||||
constructor TAndroidTimer.Create;
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkTimer));
|
||||
vAndroidPipesComm.SendInt(amkTimer_New_Runnable);
|
||||
vAndroidPipesComm.SendInt(PtrInt(Self)); // Self, Pascal pointer
|
||||
Index := vAndroidPipesComm.WaitForIntReturn();
|
||||
end;
|
||||
|
||||
procedure TAndroidTimer.postDelayed(ADelay: Integer);
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkTimer));
|
||||
vAndroidPipesComm.SendInt(amkTimer_postDelayed);
|
||||
vAndroidPipesComm.SendInt(Index); // Self
|
||||
vAndroidPipesComm.SendInt(ADelay);
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
end;
|
||||
|
||||
procedure TAndroidTimer.removeCallbacks();
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkTimer));
|
||||
vAndroidPipesComm.SendInt(amkTimer_removeCallbacks);
|
||||
vAndroidPipesComm.SendInt(Index); // Self
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
end;
|
||||
|
||||
procedure TAndroidTimer.callOnTimerListener();
|
||||
begin
|
||||
if Assigned(OnTimer) then OnTimer(Self);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user