Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Fix sync sometimes crashing when ran multiple times without reopening…
Browse files Browse the repository at this point in the history
… the app
  • Loading branch information
NerdNumber9 committed Feb 2, 2018
1 parent 8f51abf commit b28a2c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/exh/favorites/FavoritesSyncHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class FavoritesSyncHelper(val context: Context) {

try {
//Take wake + wifi locks
wakeLock?.release()
ignore { wakeLock?.release() }
wakeLock = ignore {
context.powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"ExhFavoritesSyncWakelock")
}
wifiLock?.release()
ignore { wifiLock?.release() }
wifiLock = ignore {
context.wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL,
"ExhFavoritesSyncWifi")
Expand Down Expand Up @@ -127,8 +127,14 @@ class FavoritesSyncHelper(val context: Context) {
return
} finally {
//Release wake + wifi locks
ignore { wakeLock?.release() }
ignore { wifiLock?.release() }
ignore {
wakeLock?.release()
wakeLock = null
}
ignore {
wifiLock?.release()
wifiLock = null
}
}

status.onNext(FavoritesSyncStatus.Idle())
Expand Down

0 comments on commit b28a2c3

Please sign in to comment.