Refine code style

This commit is contained in:
Mygod
2018-12-25 13:02:53 +08:00
parent b2534eb2c0
commit ec08802fbd

View File

@@ -63,7 +63,7 @@ sealed class TetheringTileService : TetherListeningTileService(), TetheringManag
} else { } else {
val binder = binder ?: return val binder = binder ?: return
state = Tile.STATE_ACTIVE state = Tile.STATE_ACTIVE
icon = if (interested.all { binder.isActive(it) }) tileOn else tileOff icon = if (interested.all(binder::isActive)) tileOn else tileOff
} }
label = getText(labelString) label = getText(labelString)
updateTile() updateTile()
@@ -91,7 +91,7 @@ sealed class TetheringTileService : TetherListeningTileService(), TetheringManag
if (interested.isEmpty()) safeInvoker { start() } else { if (interested.isEmpty()) safeInvoker { start() } else {
val binder = binder val binder = binder
if (binder == null) tapPending = true else { if (binder == null) tapPending = true else {
val inactive = interested.filter { !binder.isActive(it) } val inactive = interested.filterNot(binder::isActive)
if (inactive.isEmpty()) safeInvoker { stop() } if (inactive.isEmpty()) safeInvoker { stop() }
else ContextCompat.startForegroundService(this, Intent(this, TetheringService::class.java) else ContextCompat.startForegroundService(this, Intent(this, TetheringService::class.java)
.putExtra(TetheringService.EXTRA_ADD_INTERFACES, inactive.toTypedArray())) .putExtra(TetheringService.EXTRA_ADD_INTERFACES, inactive.toTypedArray()))
@@ -147,7 +147,7 @@ sealed class TetheringTileService : TetherListeningTileService(), TetheringManag
val binder = binder ?: return val binder = binder ?: return
state = Tile.STATE_ACTIVE state = Tile.STATE_ACTIVE
val interested = interested val interested = interested
icon = if (interested.isNotEmpty() && interested.all { binder.isActive(it) }) tileOn else tileOff icon = if (interested.isNotEmpty() && interested.all(binder::isActive)) tileOn else tileOff
} }
false -> { false -> {
state = Tile.STATE_INACTIVE state = Tile.STATE_INACTIVE
@@ -164,7 +164,7 @@ sealed class TetheringTileService : TetherListeningTileService(), TetheringManag
true -> { true -> {
val binder = binder val binder = binder
if (binder == null) tapPending = true else { if (binder == null) tapPending = true else {
val inactive = interested.filter { !binder.isActive(it) } val inactive = interested.filterNot(binder::isActive)
if (inactive.isEmpty()) safeInvoker { stop() } if (inactive.isEmpty()) safeInvoker { stop() }
else ContextCompat.startForegroundService(this, Intent(this, TetheringService::class.java) else ContextCompat.startForegroundService(this, Intent(this, TetheringService::class.java)
.putExtra(TetheringService.EXTRA_ADD_INTERFACES, inactive.toTypedArray())) .putExtra(TetheringService.EXTRA_ADD_INTERFACES, inactive.toTypedArray()))