|
@@ -389,26 +389,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
389
|
389
|
//连接不为空,并且应用已安装则跳转应用
|
390
|
390
|
if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
|
391
|
391
|
spUtils.saveJson(Const.AUTOAPPKEY,it)
|
392
|
|
- val launchIntent = Intent()
|
393
|
|
- launchIntent.setComponent(
|
394
|
|
- ComponentName(
|
395
|
|
- it.appPackage!!,
|
396
|
|
- it.authUrl!!
|
397
|
|
- )
|
398
|
|
- )
|
399
|
|
- startActivity(launchIntent)
|
|
392
|
+ startAutoApp(it)
|
400
|
393
|
}else{
|
401
|
394
|
try {
|
402
|
395
|
val autoAppBean = spUtils.getFromJson(Const.AUTOAPPKEY, AutoAppBean().javaClass) as AutoAppBean
|
403
|
|
- if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
|
404
|
|
- val launchIntent = Intent()
|
405
|
|
- launchIntent.setComponent(
|
406
|
|
- ComponentName(
|
407
|
|
- autoAppBean.appPackage!!,
|
408
|
|
- autoAppBean.authUrl!!
|
409
|
|
- )
|
410
|
|
- )
|
411
|
|
- startActivity(launchIntent)
|
|
396
|
+ if (autoAppBean.authUrl!=null&&AppUtils.isAppInstalled(this,autoAppBean.appPackage)){
|
|
397
|
+ startAutoApp(autoAppBean)
|
412
|
398
|
}else{
|
413
|
399
|
canClickFlag=true
|
414
|
400
|
}
|
|
@@ -422,6 +408,40 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
422
|
408
|
updateAllStrategy()
|
423
|
409
|
}
|
424
|
410
|
|
|
411
|
+ private fun startAutoApp(autoAppBean: AutoAppBean){
|
|
412
|
+ val launchIntent = Intent()
|
|
413
|
+ launchIntent.setComponent(
|
|
414
|
+ ComponentName(
|
|
415
|
+ autoAppBean.appPackage!!,
|
|
416
|
+ autoAppBean.authUrl!!
|
|
417
|
+ )
|
|
418
|
+ )
|
|
419
|
+ launchIntent.putExtra("authType",autoAppBean.authType)
|
|
420
|
+ userBean?.let {
|
|
421
|
+ when(autoAppBean.authType){
|
|
422
|
+ 1->{
|
|
423
|
+ val userid = it.userid
|
|
424
|
+ launchIntent.putExtra("authData",userid.toString())
|
|
425
|
+ }
|
|
426
|
+ 2->{
|
|
427
|
+ val studentno = it.studentno
|
|
428
|
+ launchIntent.putExtra("authData",studentno.toString())
|
|
429
|
+ }
|
|
430
|
+ 3->{
|
|
431
|
+ val userphone = it.userphone
|
|
432
|
+ launchIntent.putExtra("authData",userphone.toString())
|
|
433
|
+ }
|
|
434
|
+ 4->{
|
|
435
|
+ val cardid = it.cardid
|
|
436
|
+ launchIntent.putExtra("authData",cardid.toString())
|
|
437
|
+ }
|
|
438
|
+ else->{
|
|
439
|
+
|
|
440
|
+ }
|
|
441
|
+ }
|
|
442
|
+ }
|
|
443
|
+ startActivity(launchIntent)
|
|
444
|
+ }
|
425
|
445
|
private fun showSucessToast() {
|
426
|
446
|
Toaster.show(R.string.updatetips)
|
427
|
447
|
updateStrategyFlag = false
|
|
@@ -484,7 +504,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
484
|
504
|
Const.backNum++
|
485
|
505
|
if (Const.backNum > Const.UPDATESTRATEGYNUM) {
|
486
|
506
|
Const.backNum = 0
|
487
|
|
- Toaster.show(R.string.updatetips)
|
488
|
507
|
updateAllStrategy()
|
489
|
508
|
}
|
490
|
509
|
}
|
|
@@ -573,6 +592,18 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
573
|
592
|
|
574
|
593
|
override fun onResume() {
|
575
|
594
|
super.onResume()
|
|
595
|
+ lifecycleScope.launch(Dispatchers.IO){
|
|
596
|
+ try {
|
|
597
|
+ val json = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass)
|
|
598
|
+ if (json == null) {
|
|
599
|
+ Toaster.show("用户信息为空")
|
|
600
|
+ } else {
|
|
601
|
+ userBean = json as UserBean
|
|
602
|
+ }
|
|
603
|
+ }catch (e:Exception){
|
|
604
|
+
|
|
605
|
+ }
|
|
606
|
+ }
|
576
|
607
|
Const.backNum++
|
577
|
608
|
userBean?.let {
|
578
|
609
|
viewModel.postAutoAppDetail(it.regionid)
|
|
@@ -585,7 +616,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
585
|
616
|
//进入该页面20次或者点击返回键20次需要更新策略
|
586
|
617
|
lastTimeLong=System.currentTimeMillis()
|
587
|
618
|
Const.backNum = 0
|
588
|
|
- Toaster.show(R.string.updatetips)
|
589
|
619
|
updateAllStrategy()
|
590
|
620
|
}else{
|
591
|
621
|
useTimeStrategy()
|