Using SAM

This commit is contained in:
Mygod
2015-10-04 15:13:16 +08:00
parent a57c06e304
commit d111bc8282
11 changed files with 196 additions and 282 deletions
@@ -110,23 +110,19 @@ trait BaseService {
protected def changeState(s: Int, msg: String) {
val handler = new Handler(getContext.getMainLooper)
handler.post(new Runnable {
override def run() {
if (state != s) {
if (callbackCount > 0) {
val n = callbacks.beginBroadcast()
for (i <- 0 to n - 1) {
try {
callbacks.getBroadcastItem(i).stateChanged(s, msg)
} catch {
case _: Exception => // Ignore
}
}
callbacks.finishBroadcast()
handler.post(() => if (state != s) {
if (callbackCount > 0) {
val n = callbacks.beginBroadcast()
for (i <- 0 to n - 1) {
try {
callbacks.getBroadcastItem(i).stateChanged(s, msg)
} catch {
case _: Exception => // Ignore
}
state = s
}
callbacks.finishBroadcast()
}
state = s
})
}