Skip to content

Commit

Permalink
Fix broken server song existent checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Senorsen committed Aug 29, 2017
1 parent 9132cf6 commit a408722
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion wukong/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdkVersion 21
targetSdkVersion 25
versionCode 141
versionName "0.1.44"
versionName "0.1.45"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AlbumArtCache(private val context: Context) {
val cacheDir = getDiskCacheDir(DISK_CACHE_SUBDIR)
initDiskCache(cacheDir)
Log.i(TAG, "cacheDir: $cacheDir")
val memCacheSize = (Runtime.getRuntime().maxMemory() / 4).toInt()
val memCacheSize = (Runtime.getRuntime().maxMemory() / 10).toInt()
Log.i(TAG, "memCacheSize=$memCacheSize")
mMemoryCache = object : LruCache<String, Array<Bitmap>>(memCacheSize) {
override fun sizeOf(key: String, value: Array<Bitmap>): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ class WukongService : Service() {
Log.d(TAG, "preload ${protocol.song?.songKey} image " + protocol.song)

// Preload artwork image.
if (protocol.song?.artwork != null)
albumArtCache.fetch(protocol.song.artwork?.file!!, null, protocol.song.songKey)
protocol.song?.artwork?.let { artwork ->
albumArtCache.fetch(artwork.file!!, null, protocol.song.songKey)
}

val song = protocol.song!!

Expand Down Expand Up @@ -454,13 +455,13 @@ class WukongService : Service() {

Protocol.PLAY -> {

serverSentSongUpdate = true

if (protocol.song == null) {
setNotification("Channel $channelId: play null")
return
}

serverSentSongUpdate = true

val song = protocol.song

currentPlayUserId = protocol.user
Expand Down Expand Up @@ -526,12 +527,12 @@ class WukongService : Service() {
doUpdateNextSong()

// Check whether server sent us a song after 10s.
executor?.shutdown()
executor?.shutdownNow()
executor = ScheduledThreadPoolExecutor(1)
executor?.scheduleAtFixedRate({
if (serverSentSongUpdate) {
Log.i(TAG, "server already sent us a song, check executor shutdown")
executor?.shutdown()
executor?.shutdownNow()
} else {
Log.i(TAG, "server not send us a song, requesting")
sendSongUpdateRequest()
Expand Down

0 comments on commit a408722

Please sign in to comment.