黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System;
using System.Collections.Generic;
using Shared.Phone.UserCenter;
using Shared.Phone.UserCenter.SmartSound.Forms;
 
namespace Shared.Phone.SmartSound.Forms
{
    public class AddSmartSound : EditorCommonForm
    {
        
        /// 列表控件
        /// </summary>
        private VerticalListControl listView = null;
 
        private FrameLayout contentLayout = null;
        /// <summary>
        /// 当前楼层的索引
        /// </summary>
        public int CurrentIndex = 0;
        private BottomClickButton bottomClickButton = null;
        private RoomRowLayout xiaoduRowLayout = null;//小度
        private RoomRowLayout sbcRowLayout = null;
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            this.ScrollEnabled = false;
            base.SetTitleText("添加音箱");//设置标题信息
         
            contentLayout = new FrameLayout();
            this.bodyFrameLayout.AddChidren(contentLayout);
 
            IniAllDataView();
        }
 
        #region 加载本地所有数据,生成供用户选择房间的界面
 
        private void IniAllDataView()
        {
            contentLayout.RemoveAll();
 
            if (listView == null)
            {
                listView = new VerticalListControl();
                contentLayout.AddChidren(listView);
                listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(173);
            }
 
            Sound sound = new Sound();
            //添加小度音箱
            sound.Checked = false;
            sound.Name = "小度";
            sound.type = 0;
            xiaoduRowLayout = new RoomRowLayout(sound);
            listView.AddChidren(xiaoduRowLayout);
            xiaoduRowLayout.InitControl();
            xiaoduRowLayout.Right_icon.IsSelected = true;
            xiaoduRowLayout.ButtonClickEvent += (sender, e) =>
            {
                xiaoduRowLayout.Right_icon.IsSelected = true;
                sbcRowLayout.Right_icon.IsSelected = false;
                CurrentIndex = 0;
            };
 
            //添加思必驰音箱
            sound.Checked = false;
            sound.Name = "思必驰";
            sound.type = 1 ;
            sbcRowLayout = new RoomRowLayout(sound);
            listView.AddChidren(sbcRowLayout);
            sbcRowLayout.InitControl();
            sbcRowLayout.Right_icon.IsSelected = false;
            sbcRowLayout.ButtonClickEvent += (sender, e) =>
            {
                xiaoduRowLayout.Right_icon.IsSelected = false;
                sbcRowLayout.Right_icon.IsSelected = true;
                CurrentIndex = 1;
            };
 
            //跳转至第三方下载按钮
            bottomClickButton = new BottomClickButton();
            this.bodyFrameLayout.AddChidren(bottomClickButton);
            bottomClickButton.Text = "跳转至第三方APP";
            bottomClickButton.ButtonClickEvent += (sender, e) =>
            {
                //
                if (CurrentIndex == 0)
                {
                    OpenXiaoDuAPP();
 
                }
                else if (CurrentIndex == 1)
                {
                    OpenSBCAPP();
                }               
            };
 
            //bottomClickButton.Visible = false;
        }
 
        /// <summary>
        /// 小度
        /// </summary>
        private void OpenXiaoDuAPP()
        {
            bool bol = false;
            try
            {
#if Android
                bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp");
#else                
                bol=HDLUtils.OpenApp("xiaoduapp://");
#endif
 
                if (!bol)
                {
#if Android
                    HDLUtils.OpenUrl("market://details?id=com.baidu.duer.superapp");
#else
                HDLUtils.OpenUrl("https://apps.apple.com/cn/app/%E5%B0%8F%E5%BA%A6/id1437733193");
#endif
                }
            }
            catch (Exception e)
            {
                string error = e.Message;
                bol = false;
            }
        }
 
        /// <summary>
        /// 思必驰
        /// </summary>
        private void OpenSBCAPP()
        {
            bool bol = false;
            try
            {
#if Android
                bol = HDLUtils.OpenAppWithPackageName("com.aispeech.companionapp");
#else                
                bol=HDLUtils.OpenApp("AispeechMobile://");
#endif
 
                if (!bol)
                {
#if Android
                    HDLUtils.OpenUrl("market://details?id=com.aispeech.companionapp");
#else
                HDLUtils.OpenUrl("https://apps.apple.com/cn/app/id1460767442");
#endif
                }
            }
            catch (Exception e)
            {
                string error = e.Message;
                bol = false;
            }
        }
 
        #endregion
 
 
        #region ■ 自定义房间选择控件_____________________
 
        /// <summary>
        /// 房间列表行
        /// </summary>
        private class RoomRowLayout : FrameRowControl
        {
            /// <summary>
            /// 房间名称
            /// </summary>
            private NormalViewControl btnName = null;
            /// <summary>
            /// 
            /// </summary>
            private Sound sound=null;
            public MostRightIconControl Right_icon = null;
            private IconViewControl iconViewControl = null;
            private NormalViewControl bottomLine = null;
 
            /// <summary>
            /// 房间列表行
            /// </summary>
            public RoomRowLayout(Sound _sound)
            {
                this.sound = _sound;
                this.UseClickStatu = false;
                this.BackgroundColor = UserCenterColor.Current.White;
                this.Height = Application.GetRealHeight(170);
            }
 
            /// <summary>
            /// 初始化控件
            /// </summary>
            public void InitControl()
            {
                //图标
                if (sound.type == 0)
                {
                    iconViewControl = this.AddLeftIcon(81, "SmartSound/Xiaodu.png");
                }
                else
                {
                    iconViewControl = this.AddLeftIcon(81, "SmartSound/Sibici.png");
                }                              
 
                //显示文本
                btnName = this.AddLeftCaption(string.Empty, 2000);
                btnName.Height = Application.GetRealHeight(60);
                btnName.TextSize = 14;
                btnName.Y = Application.GetRealHeight(57);
                btnName.Text = sound.Name;
                //btnName.X = iconViewControl.X + iconViewControl.Width ;
 
                Right_icon = this.AddMostRightEmptyIcon(58, 58);
                Right_icon.Gravity = Gravity.CenterVertical;
 
                Right_icon.SelectedImagePath = "Item/ItemSelected.png";
                Right_icon.UnSelectedImagePath = "Item/ItemUnSelected.png";
 
                bottomLine = AddBottomLine();
                bottomLine.X = btnName.X;
            }
        }
        #endregion
 
        private class Sound
        {
            public int type = 0;
            public string Name="";
            public bool Checked = false;
        }
    }
}