wxr
2024-04-11 4536880c51cd9d39d77df3e6ea733c6e9056c891
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
using System;
using Shared;
 
namespace HDL_ON.Entity
{
    public class CommonMethod
    {
        private Loading loading;
 
        private static CommonMethod commonMethod = null;
        /// <summary>
        /// 获取对象
        /// </summary>
        public static CommonMethod Current
        {
            get
            {
                if (commonMethod == null)
                {
                    commonMethod = new CommonMethod();
                }
 
                return commonMethod;
 
            }
 
        }
 
 
        /// <summary>
        /// 获取Loading对象
        /// </summary>
        /// <returns></returns>
        public Loading Loading
        {
            get
            {
                this.MainThread(() =>
                {
                    if (loading == null)//|| MainPage.BasePageView.ChildrenCount < 1)
                    {
                        loading = new Loading();
                    }
                    Application.MainPage.AddChidren(loading);
                });
                return loading;
            }
 
        }
 
       
        #region  ---------自定义线程(子线程,主线程)--------
        /// <summary>
        /// 子线程
        /// </summary>
        /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref>
        /// <param name="action"></param>
        public void SunThread(Action action, TipType tipType = TipType.confirmation)
        {
            new System.Threading.Thread(() =>
            {
                try
                {
                    action?.Invoke();
                }
                catch (Exception e)
                {
                    this.ShowAlert(e, tipType);
                }
            })
            { IsBackground = true }.Start();
 
        }
        /// <summary>
        /// 主线程(UI更新)
        /// </summary>
        /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref>
        /// <param name="action"></param>
        public void MainThread(Action action, TipType tipType = TipType.confirmation)
        {
            Application.RunOnMainThread(() =>
            {
                try
                {
                    action?.Invoke();
                }
                catch (Exception e)
                {
                    this.ShowAlert(e, tipType);
                }
            });
 
        }
        #endregion
        #region  --------- 提示框,确认框 --------
        /// <summary>
        /// 对话框(只要程序报错的时候才用到)
        /// </summary>
        /// <paramref name="e"/>异常对象<paramref>
        /// <paramref name="tipType"/>是否要提示错误信息(默认显示)<paramref>
        private void ShowAlert(Exception e, TipType tipType)
        {
 
 
        }
 
        public void ShowTip(string msg,int time = 2)
        {
            new UI.PublicAssmebly().TipMsgAutoClose(msg, false, time);
        }
 
     
        #endregion
     
 
 
    }
 
    /// <summary>
    /// 弹框类型
    /// </summary>
    public enum TipType
    {
        none,//无提示
        flicker,//闪烁框
        confirmation//确认框
    }
    /// <summary>
    /// 表示来自那个界面
    /// </summary>
    public enum Comerom
    {
        function,//功能
        collect,//收藏
        room,//房间
        push,//推送
        sanfan,//添加第三方设备
    }
 
 
}