Skip to content

Commit

Permalink
增加当token为null时,兼容显示
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbaoxing committed Jul 8, 2021
1 parent 9a9e7e3 commit f80153c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,27 @@ internal class FloatingWindowHelper(val context: Context, var config: FloatConfi
private lateinit var touchUtils: TouchUtils
private var enterAnimator: Animator? = null

fun createWindow() = try {
fun createWindow() {
touchUtils = TouchUtils(context, config)
initParams()
addView()
config.isShow = true
} catch (e: Exception) {
config.callbacks?.createdResult(false, "$e", null)
config.floatCallbacks?.builder?.createdResult?.invoke(false, "$e", null)
if (getToken() == null) {
val activity = if (context is Activity) context else LifecycleUtils.getTopActivity()
activity?.findViewById<View>(android.R.id.content)?.post {
createWindowInner()
}
} else {
createWindowInner()
}
}

private fun createWindowInner() {
try {
initParams()
addView()
config.isShow = true
} catch (e: Exception) {
config.callbacks?.createdResult(false, "$e", null)
config.floatCallbacks?.builder?.createdResult?.invoke(false, "$e", null)
}
}

private fun initParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class MainActivity : BaseActivity(), View.OnClickListener {
openSecond.setOnClickListener(this)
openSwipeTest.setOnClickListener(this)
openBorderTest.setOnClickListener(this)

// 测试activity中onCreate就启动浮框
// showActivity2()
}

override fun onClick(v: View?) {
Expand Down

0 comments on commit f80153c

Please sign in to comment.