0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-26 13:12:59 +00:00
This commit is contained in:
X1nto 2020-05-27 21:43:21 +04:00
parent 5c7d14294a
commit 1218a56765

View file

@ -40,17 +40,14 @@ class MainActivity : Main() {
} }
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter( registerReceivers()
INSTALL_COMPLETED
))
} }
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
when (intent.action) { if (intent.action == INSTALL_COMPLETED) {
INSTALL_COMPLETED -> launchVanced() launchVanced()
else -> intent.action?.let { alertBuilder(it) }
} }
} }
} }
@ -67,9 +64,7 @@ class MainActivity : Main() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter( registerReceivers()
INSTALL_COMPLETED
))
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -148,8 +143,32 @@ class MainActivity : Main() {
.show() .show()
} }
private fun registerReceivers() {
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_COMPLETED
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_ABORTED
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_BLOCKED
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_STORAGE
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_CONFLICT
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_FAILED
))
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter(
INSTALL_INVALID
))
}
companion object { companion object {
const val BLANK_INTENT = "BLANK"
const val INSTALL_COMPLETED = "Installation completed" const val INSTALL_COMPLETED = "Installation completed"
const val INSTALL_ABORTED = "user aborted installation" const val INSTALL_ABORTED = "user aborted installation"
const val INSTALL_BLOCKED = "user blocked installation" const val INSTALL_BLOCKED = "user blocked installation"