陈嘉乐
2021-03-16 e1ac4ab0e68024e6289e0b11756962d662749b04
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI
{
    public class AddThirdPartyBrandListpage : FrameLayout
    {
        FrameLayout bodyView;
        VerticalRefreshLayout contentView;
        List<IntegratedBrand> brandList = new List<IntegratedBrand>();
        public AddThirdPartyBrandListpage()
        {
            bodyView = this;
        }
 
        public void LoadPage()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.FunctionBrand)).LoadTopView();
 
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
            contentView = new VerticalRefreshLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64),
            };
            bodyView.AddChidren(contentView);
 
 
            contentView.BeginHeaderRefreshingAction = () =>
            {
                contentView.EndHeaderRefreshing();
                Load3tyBrandList();
            };
 
            Load3tyBrandList();
        }
 
        void LoadRow(List<IntegratedBrand> brandList)
        {
            contentView.RemoveAll();
            bool isFrist = true;
            foreach(var brand in brandList)
            {
                FrameLayout row = new FrameLayout() {
                    Height = Application.GetRealHeight(50),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                };
                contentView.AddChidren(row);
 
                if(isFrist)
                {
                    isFrist = false;
                }
                else
                {
                    Button btnLine = new Button()
                    {
                        X = Application.GetRealWidth(56),
                        Y = Application.GetRealHeight(49),
                        Width = Application.GetRealWidth(303),
                        Height = 1,
                        BackgroundColor = CSS_Color.DividingLineColor,
                    };
                    row.AddChidren(btnLine);
                }
 
                ImageView btnIcon = new ImageView()
                {
                    X = Application.GetRealWidth(12),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth(32),
                    Height = Application.GetRealWidth(32),
                    Radius = (uint)Application.GetRealWidth(4),
                    BackgroundColor = CSS_Color.PromptingColor1
                    //ImagePath = "tuya_logo.png"
                };
                row.AddChidren(btnIcon);
                Button btnRight = new Button()
                {
                    X = Application.GetRealWidth(339),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(16),
                    Height = Application.GetMinRealAverage(16),
                    UnSelectedImagePath = "Public/Right.png",
                };
                row.AddChidren(btnRight);
 
                Button btnName = new Button()
                {
                    X = Application.GetRealWidth(56),
                    Width = Application.GetRealWidth(303),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = brand.brandName,
                };
                row.AddChidren(btnName);
                //下载第三方品牌icon
                ImageUtlis.Current.Load3tyBrandIconImages(brand.brandName, brand.brandIcon, btnIcon);
            }
 
        }
 
        void Load3tyBrandList()
        {
            var waitPage = new Loading();
            waitPage.Start();
            new System.Threading.Thread(() => {
                try
                {
                    var pm = new DAL.Server.HttpServerRequest();
                    var pack = pm.Get3tyBrandList();
                    if(pack.Code == DAL.Server.StateCode.SUCCESS)
                    {
                        var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<IntegratedBrand>>(pack.Data.ToString());
                        Application.RunOnMainThread(() =>
                        {
                            LoadRow(revData);
                        });
                    }
                }
                catch (Exception ex)
                {
                    MainPage.Log("1--::"+ex.Message);
                }
                finally
                {
                    Application.RunOnMainThread(() => { waitPage.Hide(); });
                }
            }) { IsBackground = true }.Start();
        }
    }
}