-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuTesteCardList.pas
83 lines (62 loc) · 1.83 KB
/
uTesteCardList.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
unit uTesteCardList;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, system.Generics.Collections, FMX.Controls.Presentation,
FMX.StdCtrls, FMX.Objects,
SYstem.JSON,
uCardList, System.Net.URLClient, System.Net.HttpClient, System.Net.HttpClientComponent, FMX.Layouts;
type
TForm2 = class(TForm)
Button1: TButton;
http: TNetHTTPClient;
Layout1: TLayout;
Lin01: TText;
Lin02: TText;
CardList1: TCardList;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
Uses
uImageDownload,
uCardTeste;
{$R *.fmx}
procedure TForm2.Button1Click(Sender: TObject);
Var
i : Integer;
aStr : TStringStream;
aArr : TJsonArray;
Ltick : Cardinal;
begin
LTick := TThread.GetTickCount;
aStr := TStringStream.Create;
Http.Get('https://app.jusimperium.com.br/Prods5000.json', aStr);
aArr := TJsonObject.ParseJSONValue(aStr.DataString) As TJsonArray;
Lin01.Text := 'Baixar 5000 produtos = '+(TThread.GetTickCount-LTick).ToString+'ms';
LTick := TThread.GetTickCount;
CardTeste.Columns := 2;
CardList1.BeginUpdate;
for i := 0 to aArr.Count-1 do
CardList1.AddCard(CardTeste, aArr.Items[i] As TJsonObject);
CardList1.EndUpdate;
aStr.DisposeOf;
Lin02.Text := 'Gerar lista de 5000 produtos = '+(TThread.GetTickCount-LTick).ToString+'ms';
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
CardList1.DeleteCard(2);
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
TImageDownload.ClearCache;
end;
end.