Browse Source

1.增加网络状态判断提醒弹窗。

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
edb9ab267d

+ 23
- 0
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

27
 import com.xhly.corelib.utils.AppUtils
27
 import com.xhly.corelib.utils.AppUtils
28
 import com.xhly.corelib.utils.GsonUtils
28
 import com.xhly.corelib.utils.GsonUtils
29
 import com.xhly.corelib.utils.LogShow
29
 import com.xhly.corelib.utils.LogShow
30
+import com.xhly.corelib.utils.NetworkUtils
30
 import com.xhly.corelib.utils.SystemUtil
31
 import com.xhly.corelib.utils.SystemUtil
31
 import com.xhly.manageapp.ManageApplication
32
 import com.xhly.manageapp.ManageApplication
32
 import com.xhly.manageapp.bean.EventLog
33
 import com.xhly.manageapp.bean.EventLog
53
     //如果次数大于10则可以打开设置页面
54
     //如果次数大于10则可以打开设置页面
54
     private var showSettingNum=0
55
     private var showSettingNum=0
55
     private var waitDialog:WaitDialog?=null
56
     private var waitDialog:WaitDialog?=null
57
+    private var tipsDialog:CustomDialog?=null
56
     override fun getBinding() = ActivityLoginBinding.inflate(layoutInflater)
58
     override fun getBinding() = ActivityLoginBinding.inflate(layoutInflater)
57
 
59
 
58
     override fun initData() {
60
     override fun initData() {
271
 
273
 
272
     override fun onResume() {
274
     override fun onResume() {
273
         super.onResume()
275
         super.onResume()
276
+        if (!NetworkUtils.isAvailable(this)){
277
+            showTipsDialog(getString(R.string.checknettips))
278
+        }
274
         useTimeStrategy()
279
         useTimeStrategy()
275
     }
280
     }
276
 
281
 
403
 
408
 
404
     }
409
     }
405
 
410
 
411
+    private fun showTipsDialog(msg: String) {
412
+        tipsDialog?.dismiss()
413
+        tipsDialog=CustomDialog.build()
414
+            .setCustomView(object : OnBindView<CustomDialog>(R.layout.layout_notice_dialog) {
415
+                override fun onBind(dialog: CustomDialog, v: View) {
416
+                    val closeBtn = v.findViewById<Button>(R.id.dialog_close_btn)
417
+                    val titleTv = v.findViewById<TextView>(R.id.dialog_title_tv)
418
+                    val contentTv = v.findViewById<TextView>(R.id.dialog_content_tv)
419
+                    contentTv.text=msg
420
+                    titleTv.text="通知"
421
+                    closeBtn.setOnClickListener {
422
+                        dialog.dismiss()
423
+                    }
424
+                }
425
+            }).setCancelable(false).setMaskColor(Color.parseColor("#66000000"))
426
+            .setAlign(CustomDialog.ALIGN.CENTER).show()
427
+    }
428
+
406
     private fun postLogPush(pushType:Int){
429
     private fun postLogPush(pushType:Int){
407
         val pushBean=LogPushBean()
430
         val pushBean=LogPushBean()
408
         pushBean.pushType=pushType
431
         pushBean.pushType=pushType

+ 22
- 0
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

121
     private var autoAppFlag=true
121
     private var autoAppFlag=true
122
 
122
 
123
     private var accountDialog:CustomDialog?=null
123
     private var accountDialog:CustomDialog?=null
124
+    private var tipsDialog:CustomDialog?=null
124
 
125
 
125
     //标记是否可以点击啊
126
     //标记是否可以点击啊
126
     private var canClickFlag=false
127
     private var canClickFlag=false
1299
             }
1300
             }
1300
 
1301
 
1301
             Const.ACTION_SCREEN_ON->{
1302
             Const.ACTION_SCREEN_ON->{
1303
+                if (!NetworkUtils.isAvailable(this)){
1304
+                  showTipsDialog(getString(R.string.checknettips))
1305
+                }
1302
                 StrategyUtils.getSchoolDeviceSetBean(this)?.let {
1306
                 StrategyUtils.getSchoolDeviceSetBean(this)?.let {
1303
                     startTimeTask(it,true)
1307
                     startTimeTask(it,true)
1304
                 }
1308
                 }
1570
             .setAlign(CustomDialog.ALIGN.CENTER).show()
1574
             .setAlign(CustomDialog.ALIGN.CENTER).show()
1571
     }
1575
     }
1572
 
1576
 
1577
+    private fun showTipsDialog(msg: String) {
1578
+        tipsDialog?.dismiss()
1579
+        tipsDialog=CustomDialog.build()
1580
+            .setCustomView(object : OnBindView<CustomDialog>(R.layout.layout_notice_dialog) {
1581
+                override fun onBind(dialog: CustomDialog, v: View) {
1582
+                    val closeBtn = v.findViewById<Button>(R.id.dialog_close_btn)
1583
+                    val titleTv = v.findViewById<TextView>(R.id.dialog_title_tv)
1584
+                    val contentTv = v.findViewById<TextView>(R.id.dialog_content_tv)
1585
+                    contentTv.text=msg
1586
+                    titleTv.text="通知"
1587
+                    closeBtn.setOnClickListener {
1588
+                        dialog.dismiss()
1589
+                    }
1590
+                }
1591
+            }).setCancelable(false).setMaskColor(Color.parseColor("#66000000"))
1592
+            .setAlign(CustomDialog.ALIGN.CENTER).show()
1593
+    }
1594
+
1573
     private fun loginOut(hasUser: Boolean = true) {
1595
     private fun loginOut(hasUser: Boolean = true) {
1574
         //没有用户信息时,判断为初次调用,直接跳转登录页面
1596
         //没有用户信息时,判断为初次调用,直接跳转登录页面
1575
         if (hasUser) {
1597
         if (hasUser) {

Loading…
Cancel
Save