Skip to content

Commit

Permalink
Check QsTile is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Aug 9, 2016
1 parent 4b5c940 commit 10725c3
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/main/scala/com/github/shadowsocks/ShadowsocksTileService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext
def trafficUpdated(txRate: Long, rxRate: Long, txTotal: Long, rxTotal: Long) = ()
def stateChanged(state: Int, msg: String) {
val tile = getQsTile
state match {
case State.STOPPED =>
tile.setIcon(iconIdle)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_INACTIVE)
case State.CONNECTED =>
tile.setIcon(iconConnected)
tile.setLabel(app.currentProfile match {
case Some(profile) => profile.name
case None => getString(R.string.app_name)
})
tile.setState(Tile.STATE_ACTIVE)
case _ =>
tile.setIcon(iconBusy)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_UNAVAILABLE)
if (tile != null) {
state match {
case State.STOPPED =>
tile.setIcon(iconIdle)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_INACTIVE)
case State.CONNECTED =>
tile.setIcon(iconConnected)
tile.setLabel(app.currentProfile match {
case Some(profile) => profile.name
case None => getString(R.string.app_name)
})
tile.setState(Tile.STATE_ACTIVE)
case _ =>
tile.setIcon(iconBusy)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_UNAVAILABLE)
}
tile.updateTile
}
tile.updateTile
}
}

Expand Down

0 comments on commit 10725c3

Please sign in to comment.