Skip to content

Commit

Permalink
🎨 优化写法
Browse files Browse the repository at this point in the history
  • Loading branch information
985892345 committed Mar 1, 2023
1 parent 13d6533 commit 4e9c423
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ val layout = findViewById<FrameLayout>(R.id.layout)
findViewById<Button>(R.id.btn_sso_login).apply {
setOnClickListener {
lifecycleScope.launch {
val data = SSOUtils.login(this@MainActivity, layout)
val data = SSOUtils.login(layout)
Toast.makeText(this@MainActivity, data.toString(), Toast.LENGTH_SHORT).show()
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/yan/redrocksso/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MainActivity : AppCompatActivity() {
setOnClickListener {
Toast.makeText(this@MainActivity, "SSO登陆", Toast.LENGTH_SHORT).show()
lifecycleScope.launch {
val data = SSOUtils.login(this@MainActivity, layout)
val data = SSOUtils.login(layout)
Toast.makeText(this@MainActivity, data.toString(), Toast.LENGTH_SHORT).show()
}
}
Expand Down
4 changes: 2 additions & 2 deletions sso/src/main/java/com/redrock/sso/SSOUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ object SSOUtils {
*
* @param parent 父布局,WebView 将会显示在该布局中,在登录成功或者协程被取消时移除 WebView
*/
suspend fun login(context: Context, parent: ViewGroup): Data {
val webView = createWebView(context, parent)
suspend fun login(parent: ViewGroup): Data {
val webView = createWebView(parent.context, parent)
try {
val data = createServer()
parent.removeView(webView)
Expand Down

0 comments on commit 4e9c423

Please sign in to comment.