all: general cleanup

General cleanup. About to do another major playback change, so
push these changes now so they are not changed later.
This commit is contained in:
OxygenCobalt
2022-01-09 08:22:14 -07:00
parent d4904136c0
commit 5e3569d173
10 changed files with 12 additions and 14 deletions
@@ -39,7 +39,6 @@ import org.oxycblt.auxio.util.systemBarsCompat
/**
* A [Fragment] that displays more information about the song, along with more media controls.
* Instantiation is done by the navigation component, **do not instantiate this fragment manually.**
* TODO: Show playing from on this screen now
* @author OxygenCobalt
*/
class PlaybackFragment : Fragment() {
@@ -80,7 +80,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
/** The current [PlaybackMode] that also determines the queue */
val playbackMode: LiveData<PlaybackMode> get() = mMode
private val playbackManager = PlaybackStateManager.maybeGetInstance()
private val playbackManager = PlaybackStateManager.getInstance()
private val settingsManager = SettingsManager.getInstance()
init {
@@ -40,7 +40,7 @@ import kotlin.math.min
* - If you want to use the playback state in the UI, use [org.oxycblt.auxio.playback.PlaybackViewModel] as it can withstand volatile UIs.
* - If you want to use the playback state with the ExoPlayer instance or system-side things, use [org.oxycblt.auxio.playback.system.PlaybackService].
*
* All access should be done with [PlaybackStateManager.maybeGetInstance].
* All access should be done with [PlaybackStateManager.getInstance].
* @author OxygenCobalt
*/
class PlaybackStateManager private constructor() {
@@ -522,7 +522,6 @@ class PlaybackStateManager private constructor() {
)
)
// TODO: Re-add state saving
database.writeQueue(mQueue)
this@PlaybackStateManager.logD(
@@ -643,7 +642,7 @@ class PlaybackStateManager private constructor() {
/**
* Get/Instantiate the single instance of [PlaybackStateManager].
*/
fun maybeGetInstance(): PlaybackStateManager {
fun getInstance(): PlaybackStateManager {
val currentInstance = INSTANCE
if (currentInstance != null) {
@@ -43,7 +43,7 @@ class AudioReactor(
) : AudioManager.OnAudioFocusChangeListener, SettingsManager.Callback {
private data class Gain(val track: Float, val album: Float)
private val playbackManager = PlaybackStateManager.maybeGetInstance()
private val playbackManager = PlaybackStateManager.getInstance()
private val settingsManager = SettingsManager.getInstance()
private val audioManager = context.getSystemServiceSafe(AudioManager::class)
@@ -46,8 +46,9 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.takeWhile
import kotlinx.coroutines.launch
import org.oxycblt.auxio.BuildConfig
@@ -74,7 +75,6 @@ import org.oxycblt.auxio.widgets.WidgetProvider
* @author OxygenCobalt
*/
class PlaybackService : Service(), Player.Listener, PlaybackStateManager.Callback, SettingsManager.Callback {
// Player components
private lateinit var player: ExoPlayer
private lateinit var mediaSession: MediaSessionCompat
@@ -90,7 +90,7 @@ class PlaybackService : Service(), Player.Listener, PlaybackStateManager.Callbac
private val systemReceiver = SystemEventReceiver()
// Managers
private val playbackManager = PlaybackStateManager.maybeGetInstance()
private val playbackManager = PlaybackStateManager.getInstance()
private val settingsManager = SettingsManager.getInstance()
// State
@@ -39,7 +39,7 @@ class PlaybackSessionConnector(
private val player: Player,
private val mediaSession: MediaSessionCompat
) : PlaybackStateManager.Callback, Player.Listener, MediaSessionCompat.Callback() {
private val playbackManager = PlaybackStateManager.maybeGetInstance()
private val playbackManager = PlaybackStateManager.getInstance()
private val emptyMetadata = MediaMetadataCompat.Builder().build()
init {
@@ -33,7 +33,7 @@ import org.oxycblt.auxio.settings.SettingsManager
class WidgetController(private val context: Context) :
PlaybackStateManager.Callback,
SettingsManager.Callback {
private val playbackManager = PlaybackStateManager.maybeGetInstance()
private val playbackManager = PlaybackStateManager.getInstance()
private val settingsManager = SettingsManager.getInstance()
private val widget = WidgetProvider()