Browse Source

1.有单点登录时,即使没有自动拉起,也会传递数据给应用,用来直接登录。

0423x6e6f
wangwanlei 3 weeks ago
parent
commit
60c1ab1058

+ 49
- 2
app/src/main/java/com/xhly/manageapp/AppAdapter.kt View File

@@ -1,6 +1,7 @@
1 1
 package com.xhly.manageapp
2 2
 
3 3
 import DownLoadUtils
4
+import android.content.ComponentName
4 5
 import android.content.Context
5 6
 import android.content.Intent
6 7
 import android.provider.Settings
@@ -14,10 +15,14 @@ import com.xhly.corelib.Const
14 15
 import com.xhly.corelib.bean.AppInfo
15 16
 import com.xhly.corelib.eventbus.UIEvent
16 17
 import com.xhly.corelib.utils.AppUtils
18
+import com.xhly.corelib.utils.GsonUtils
17 19
 import com.xhly.corelib.utils.LogShow
18 20
 import com.xhly.corelib.utils.ModelNameUtils
19 21
 import com.xhly.corelib.utils.NetworkUtils
22
+import com.xhly.corelib.utils.SharedPreferencesUtils
20 23
 import com.xhly.corelib.utils.SystemUtil
24
+import com.xhly.manageapp.bean.scheme.AutoAppBean
25
+import com.xhly.manageapp.bean.user.UserBean
21 26
 import com.xhly.manageapp.utils.InstallUtils
22 27
 import com.xhly.manageapp.utils.StrategyUtils
23 28
 import java.util.Calendar
@@ -29,6 +34,8 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
29 34
      var lastTimeLong=0L
30 35
      //用来判断1s内的连点
31 36
      var lastClickLong=0L
37
+     var userBean:UserBean?=null
38
+    val spUtils by lazy { SharedPreferencesUtils.getInstance(context) }
32 39
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AppViewHolder {
33 40
         val inflate = ItemAppBinding.inflate(LayoutInflater.from(context), parent, false)
34 41
         return AppViewHolder(inflate)
@@ -136,13 +143,53 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
136 143
                         Toaster.show("应用正在安装,请稍后")
137 144
                         return@setOnClickListener
138 145
                     }
139
-                    var instance = Calendar.getInstance()
146
+                    val instance = Calendar.getInstance()
140 147
                     instance.set(Calendar.HOUR_OF_DAY, 11)
141 148
                     instance.set(Calendar.MINUTE, 0)
142 149
                     /* context.startActivity(appInfo.intent)*/
143 150
                     val appTimeStrategy = StrategyUtils.getAppTimeStrategy(context, appInfo.packageName)
144 151
                     if (appTimeStrategy){
145
-                        context.startActivity(appInfo.intent)
152
+                        //然后根据自动拉起和单点登录判断打开时是否传递登录数据
153
+                        if (userBean!=null){
154
+                            userBean?.let {
155
+                                if (it.sso==2){
156
+                                    //单点登录则传递数据,否则不传递,单点登录同样有两种情况,一种是拉起,一种是不拉起,拉起的则指定页面跳转,否则不指定
157
+                                    val autoAppBean = spUtils.getFromJson(
158
+                                        Const.AUTOAPPKEY,
159
+                                        AutoAppBean().javaClass
160
+                                    ) as? AutoAppBean
161
+                                    if (autoAppBean!=null){
162
+                                        val launchIntent = Intent()
163
+                                        launchIntent.setComponent(
164
+                                            ComponentName(
165
+                                                autoAppBean.appPackage!!,
166
+                                                autoAppBean.authUrl!!
167
+                                            )
168
+                                        )
169
+                                        launchIntent.putExtra("authType", autoAppBean.authType)
170
+                                        userBean?.let {
171
+                                            val parseClassToJson = GsonUtils.parseClassToJson(it)
172
+                                            launchIntent.putExtra("authData", parseClassToJson)
173
+                                        }
174
+                                        context.startActivity(launchIntent)
175
+                                    }else{
176
+                                        //单点不拉起,则传递数据,但是不指定页面专挑
177
+                                        val intent = appInfo.intent
178
+                                        intent.putExtra("authType", userBean?.authType)
179
+                                        userBean?.let {
180
+                                            val parseClassToJson = GsonUtils.parseClassToJson(it)
181
+                                            intent.putExtra("authData", parseClassToJson)
182
+                                        }
183
+                                        context.startActivity(intent)
184
+                                    }
185
+                                }else{
186
+                                    //非单点登录还走之前的跳转
187
+                                    context.startActivity(appInfo.intent)
188
+                                }
189
+                            }
190
+                        }else{
191
+                            context.startActivity(appInfo.intent)
192
+                        }
146 193
                     }else{
147 194
                         Toaster.showLong(context.getString(R.string.apptimestoptips))
148 195
                     }

+ 1
- 1
app/src/main/java/com/xhly/manageapp/bean/user/UserBean.kt View File

@@ -100,7 +100,7 @@ class UserBean {
100 100
     var regionName:String?=null
101 101
 
102 102
     /**
103
-     * 单点登录:1平台2自定义
103
+     * 单点登录:1平台2自定义  为2表示单点登录需要传递数据,否则不传递
104 104
      */
105 105
     var sso:Int=1
106 106
     /**

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

@@ -234,6 +234,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
234 234
                 registerSDReceiver()
235 235
                 registerLoginOutReceiver()
236 236
                 registerXhlyUpdeteStrategyReceiver()
237
+                adapter?.userBean=it
237 238
             }
238 239
         }catch (e:Exception){
239 240
             LogShow("错误是"+e.toString())

Loading…
Cancel
Save