Skip to content

Commit 2ad4d34

Browse files
committed
add sample location
1 parent ec77b34 commit 2ad4d34

File tree

3 files changed

+71
-3
lines changed

3 files changed

+71
-3
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "com.duy.pascal.compiler"
77
minSdkVersion 14
88
targetSdkVersion 25
9-
versionCode 92
10-
versionName "3.9.1"
9+
versionCode 93
10+
versionName "3.9.2"
1111
vectorDrawables.useSupportLibrary = true
1212

1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

libCompiler/src/main/java/com/duy/pascal/frontend/code_editor/editor_view/HighlightEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public Editable highlight(Editable editable, boolean newText) {
782782
firstVisibleIndex = 0;
783783
lastVisibleIndex = CHARS_TO_COLOR;
784784
}
785-
int delta = (lastVisibleIndex - firstVisibleIndex) / 5;
785+
int delta = (lastVisibleIndex - firstVisibleIndex) / 3;
786786
firstVisibleIndex -= delta;
787787
lastVisibleIndex += delta;
788788

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{declare library aLocation}
2+
uses
3+
aLocation, crt;
4+
5+
{declare type java}
6+
type
7+
map = java_util_Map;{https://docs.oracle.com/javase/7/docs/api/java/util/Map.html}
8+
list = java_util_List; {https://docs.oracle.com/javase/7/docs/api/java/util/List.html}
9+
obj = java_lang_Object;
10+
loc = android_location_Location;
11+
{https://developer.android.com/reference/android/location/Location.html}
12+
var
13+
i: Integer;
14+
data: map; {Location data will be saved here}
15+
16+
{This method will be print data to console,
17+
include latitude, longitude,....}
18+
procedure printData(data: map);
19+
var
20+
providers: list;
21+
i: Integer;
22+
name: obj; //the name of provider
23+
info: loc; //store data of location
24+
begin
25+
{Each provider has a set of criteria under
26+
which it may be used; for example, some providers
27+
require GPS hardware and visibility to a number
28+
of satellites; others require the use of the
29+
cellular radio, or access to a specific carrier's
30+
network, or to the internet.}
31+
32+
{Returns available providers on the phone}
33+
providers := locationProviders();
34+
35+
for i := 0 to providers.size() - 1 do
36+
begin
37+
name := providers.get(i); //get name of provider in position i
38+
39+
if (data.get(name) <> null) then //if the data of provider is exist
40+
begin
41+
cast(info, data.get(name));
42+
43+
//print long,lat to console
44+
writeln('getLatitude = ', info.getLatitude());
45+
writeln('getLongitude = ', info.getLongitude());
46+
end;
47+
end;
48+
writeln;
49+
end;
50+
51+
52+
begin
53+
{Starts collecting location data.
54+
The first parameter is minimum time between updates in milliseconds
55+
The second parameter is minimum distance between updates in meters}
56+
startLocating(100, 10);
57+
58+
//wait for 60 second
59+
for i := 1 to 60 do
60+
begin
61+
delay(1000); //wait for collect info
62+
data := readLocation(); //read data
63+
printData(data); //print data to console
64+
end;
65+
66+
//stop collect data
67+
stopLocating();
68+
end.

0 commit comments

Comments
 (0)