Created
May 21, 2019 09:35
-
-
Save hwd6190128/57f295575a8c6d6bc89f8b2bfc35366c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// prefer one | |
private val immersiveRunnable = Runnable { | |
immersiveMode(this@BaseActivity) | |
} | |
companion object { | |
private const val INITIAL_HIDE_DELAY = 300L | |
} | |
override fun onWindowFocusChanged(hasFocus: Boolean) { | |
super.onWindowFocusChanged(hasFocus) | |
if (hasFocus) { | |
handler.postDelayed(immersiveRunnable, BaseActivity.INITIAL_HIDE_DELAY) | |
} else { | |
handler.removeCallbacksAndMessages(immersiveRunnable) | |
} | |
} | |
// last resort | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// ... | |
window.decorView.setOnSystemUiVisibilityChangeListener { | |
if (it and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) { | |
immersiveMode(this@BaseActivity) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment