mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-18 19:17:15 +00:00
Added some compile-time performance improvements and removed some
extraneous Kotlin code.
This commit is contained in:
parent
a0f1b8a39c
commit
a5a5cfa956
@ -32,9 +32,15 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug {
|
||||||
|
minifyEnabled false
|
||||||
|
ext.enableCrashlytics = false
|
||||||
|
ext.alwaysUpdateBuildId = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,36 +53,36 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
|
||||||
compile(name:'android-taskrunner-0.5', ext:'aar')
|
implementation(name:'android-taskrunner-0.5', ext:'aar')
|
||||||
|
|
||||||
compile(name:'videocache-2.8.0-pre', ext:'aar')
|
implementation(name:'videocache-2.8.0-pre', ext:'aar')
|
||||||
compile 'org.slf4j:slf4j-android:1.7.21'
|
implementation 'org.slf4j:slf4j-android:1.7.21'
|
||||||
|
|
||||||
compile "android.arch.persistence.room:runtime:1.0.0-alpha3"
|
implementation "android.arch.persistence.room:runtime:1.0.0-alpha3"
|
||||||
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha3"
|
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha3"
|
||||||
kapt "android.arch.persistence.room:compiler:1.0.0-alpha3"
|
kapt "android.arch.persistence.room:compiler:1.0.0-alpha3"
|
||||||
|
|
||||||
compile 'com.neovisionaries:nv-websocket-client:1.31'
|
implementation 'com.neovisionaries:nv-websocket-client:1.31'
|
||||||
compile 'com.squareup.okhttp3:okhttp:3.8.0'
|
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
|
||||||
compile 'com.github.bumptech.glide:glide:3.8.0'
|
implementation 'com.github.bumptech.glide:glide:3.8.0'
|
||||||
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
|
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
|
||||||
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||||
compile 'com.google.android.exoplayer:exoplayer:r2.4.2'
|
implementation 'com.google.android.exoplayer:exoplayer:r2.4.2'
|
||||||
compile 'com.google.android.exoplayer:extension-okhttp:r2.4.2'
|
implementation 'com.google.android.exoplayer:extension-okhttp:r2.4.2'
|
||||||
compile 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar'
|
implementation 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar'
|
||||||
compile 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
|
|
||||||
compile 'com.android.support:appcompat-v7:25.4.0'
|
implementation 'com.android.support:appcompat-v7:25.4.0'
|
||||||
compile 'com.android.support:recyclerview-v7:25.4.0'
|
implementation 'com.android.support:recyclerview-v7:25.4.0'
|
||||||
compile 'com.android.support:design:25.4.0'
|
implementation 'com.android.support:design:25.4.0'
|
||||||
|
|
||||||
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
|
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,19 +7,11 @@ interface PlaybackService {
|
|||||||
fun disconnect(listener: () -> Unit)
|
fun disconnect(listener: () -> Unit)
|
||||||
|
|
||||||
fun playAll()
|
fun playAll()
|
||||||
|
|
||||||
fun playAll(index: Int, filter: String)
|
fun playAll(index: Int, filter: String)
|
||||||
|
fun play(category: String, categoryId: Long, index: Int, filter: String)
|
||||||
fun play(
|
|
||||||
category: String,
|
|
||||||
categoryId: Long,
|
|
||||||
index: Int,
|
|
||||||
filter: String)
|
|
||||||
|
|
||||||
fun playAt(index: Int)
|
fun playAt(index: Int)
|
||||||
|
|
||||||
fun pauseOrResume()
|
fun pauseOrResume()
|
||||||
|
|
||||||
fun pause()
|
fun pause()
|
||||||
fun resume()
|
fun resume()
|
||||||
fun prev()
|
fun prev()
|
||||||
|
@ -28,9 +28,11 @@ import io.casey.musikcube.remote.util.Strings
|
|||||||
import io.casey.musikcube.remote.websocket.Prefs
|
import io.casey.musikcube.remote.websocket.Prefs
|
||||||
import android.support.v4.app.NotificationCompat.Action as NotifAction
|
import android.support.v4.app.NotificationCompat.Action as NotifAction
|
||||||
|
|
||||||
/* basically a stub service that exists to keep a connection active to the
|
/**
|
||||||
StreamingPlaybackService, which keeps music playing. TODO: should also hold
|
* a service used to interact with all of the system media-related components -- notifications,
|
||||||
a partial wakelock to keep the radio from going to sleep. */
|
* lock screen controls, and headset events. also holds a partial wakelock to keep the system
|
||||||
|
* from completely falling asleep during streaming playback.
|
||||||
|
*/
|
||||||
class SystemService : Service() {
|
class SystemService : Service() {
|
||||||
private val handler = Handler()
|
private val handler = Handler()
|
||||||
private var prefs: SharedPreferences? = null
|
private var prefs: SharedPreferences? = null
|
||||||
@ -53,7 +55,6 @@ class SystemService : Service() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
recycleAlbumArt()
|
|
||||||
unregisterReceivers()
|
unregisterReceivers()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,34 +105,23 @@ class SystemService : Service() {
|
|||||||
private fun shutdownNow() {
|
private fun shutdownNow() {
|
||||||
Log.d(TAG, "SystemService SHUT_DOWN")
|
Log.d(TAG, "SystemService SHUT_DOWN")
|
||||||
|
|
||||||
if (mediaSession != null) {
|
mediaSession?.release()
|
||||||
mediaSession?.release()
|
mediaSession = null
|
||||||
}
|
|
||||||
|
|
||||||
if (playback != null) {
|
playback?.disconnect(playbackListener)
|
||||||
playback?.disconnect(playbackListener)
|
playback = null
|
||||||
playback = null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wakeLock != null) {
|
wakeLock?.release()
|
||||||
wakeLock?.release()
|
wakeLock = null
|
||||||
wakeLock = null
|
|
||||||
}
|
|
||||||
|
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sleepNow() {
|
private fun sleepNow() {
|
||||||
Log.d(TAG, "SystemService SLEEP")
|
Log.d(TAG, "SystemService SLEEP")
|
||||||
|
wakeLock?.release()
|
||||||
if (wakeLock != null) {
|
wakeLock = null
|
||||||
wakeLock?.release()
|
playback?.disconnect(playbackListener)
|
||||||
wakeLock = null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playback != null) {
|
|
||||||
playback?.disconnect(playbackListener)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initMediaSession() {
|
private fun initMediaSession() {
|
||||||
@ -140,7 +130,8 @@ class SystemService : Service() {
|
|||||||
mediaSession = MediaSessionCompat(this, "musikdroid.SystemService", receiver, null)
|
mediaSession = MediaSessionCompat(this, "musikdroid.SystemService", receiver, null)
|
||||||
|
|
||||||
mediaSession?.setFlags(
|
mediaSession?.setFlags(
|
||||||
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS)
|
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or
|
||||||
|
MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS)
|
||||||
|
|
||||||
mediaSession?.setCallback(mediaSessionCallback)
|
mediaSession?.setCallback(mediaSessionCallback)
|
||||||
|
|
||||||
@ -194,14 +185,8 @@ class SystemService : Service() {
|
|||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized private fun recycleAlbumArt() {
|
|
||||||
if (albumArt != null) {
|
|
||||||
albumArt = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun downloadAlbumArt(title: String, artist: String, album: String, duration: Int) {
|
private fun downloadAlbumArt(title: String, artist: String, album: String, duration: Int) {
|
||||||
recycleAlbumArt()
|
albumArt = null
|
||||||
|
|
||||||
albumArtModel = AlbumArtModel(title, artist, album, AlbumArtModel.Size.Mega) {
|
albumArtModel = AlbumArtModel(title, artist, album, AlbumArtModel.Size.Mega) {
|
||||||
_: AlbumArtModel, url: String? ->
|
_: AlbumArtModel, url: String? ->
|
||||||
@ -252,7 +237,7 @@ class SystemService : Service() {
|
|||||||
currentImage = albumArt
|
currentImage = albumArt
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
recycleAlbumArt()
|
albumArt = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,11 +412,10 @@ class SystemService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onMediaButtonEvent(mediaButtonEvent)
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlay() {
|
override fun onPlay() {
|
||||||
super.onPlay()
|
|
||||||
if (playback?.queueCount == 0) {
|
if (playback?.queueCount == 0) {
|
||||||
playback?.playAll()
|
playback?.playAll()
|
||||||
}
|
}
|
||||||
@ -441,27 +425,22 @@ class SystemService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
|
||||||
playback?.pause()
|
playback?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSkipToNext() {
|
override fun onSkipToNext() {
|
||||||
super.onSkipToNext()
|
|
||||||
playback?.next()
|
playback?.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSkipToPrevious() {
|
override fun onSkipToPrevious() {
|
||||||
super.onSkipToPrevious()
|
|
||||||
playback?.prev()
|
playback?.prev()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFastForward() {
|
override fun onFastForward() {
|
||||||
super.onFastForward()
|
|
||||||
playback?.seekForward()
|
playback?.seekForward()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRewind() {
|
override fun onRewind() {
|
||||||
super.onRewind()
|
|
||||||
playback?.seekBackward()
|
playback?.seekBackward()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,5 @@
|
|||||||
# Project-wide Gradle settings.
|
|
||||||
|
|
||||||
# IDE (e.g. Android Studio) users:
|
|
||||||
# Gradle settings configured through the IDE *will override*
|
|
||||||
# any settings specified in this file.
|
|
||||||
|
|
||||||
# For more details on how to configure your build environment visit
|
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
||||||
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
org.gradle.caching=true
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
Loading…
x
Reference in New Issue
Block a user