Clean code

Do some codebase cleaning.
This commit is contained in:
OxygenCobalt 2021-02-20 16:35:36 -07:00
parent 4efbab8b05
commit 89174b8011
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
10 changed files with 24 additions and 45 deletions

View file

@ -7,7 +7,6 @@ import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.BaseModel import org.oxycblt.auxio.music.BaseModel
import org.oxycblt.auxio.music.Genre import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.MusicStore
import org.oxycblt.auxio.recycler.SortMode import org.oxycblt.auxio.recycler.SortMode
/** /**
@ -41,8 +40,6 @@ class DetailViewModel : ViewModel() {
private val mNavToItem = MutableLiveData<BaseModel?>() private val mNavToItem = MutableLiveData<BaseModel?>()
val navToItem: LiveData<BaseModel?> get() = mNavToItem val navToItem: LiveData<BaseModel?> get() = mNavToItem
private val musicStore = MusicStore.getInstance()
/** /**
* Update the current navigation status * Update the current navigation status
* @param value Whether the current [DetailFragment] is navigating or not. * @param value Whether the current [DetailFragment] is navigating or not.

View file

@ -77,8 +77,9 @@ class MusicLinker(
* no, why would ANYONE do that? Instead, I have to manually iterate through each genre, get * no, why would ANYONE do that? Instead, I have to manually iterate through each genre, get
* A LIST OF SONGS FROM THEM, and then waste CPU cycles REPEATEDLY ITERATING through the * A LIST OF SONGS FROM THEM, and then waste CPU cycles REPEATEDLY ITERATING through the
* songs list to LINK EACH SONG WITH THEIR GENRE. Why is it this way? Nobody knows! Now this * songs list to LINK EACH SONG WITH THEIR GENRE. Why is it this way? Nobody knows! Now this
* quirk is immortalized and has to be replicated in all future iterations of the API! * quirk is immortalized and has to be replicated in all future iterations of this API! Yay!
* Yay! I hate this platform so much. *
* I hate this platform so much.
*/ */
genres.forEach { genre -> genres.forEach { genre ->
val songCursor = resolver.query( val songCursor = resolver.query(

View file

@ -10,18 +10,16 @@ import androidx.core.database.getStringOrNull
import org.oxycblt.auxio.R import org.oxycblt.auxio.R
import org.oxycblt.auxio.logD import org.oxycblt.auxio.logD
import org.oxycblt.auxio.music.Album import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.Genre import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.music.toAlbumArtURI import org.oxycblt.auxio.music.toAlbumArtURI
/** /**
* Class that loads/constructs [Genre]s, [Album]s, and [Song] objects from the filesystem * Class that loads/constructs [Genre]s, [Album]s, and [Song] objects from the filesystem
* Artists are constructed in [MusicSorter], as they are only really containers for [Album]s * Artists are constructed in [MusicLinker], as they are only really containers for [Album]s
*/ */
class MusicLoader(private val app: Application) { class MusicLoader(private val app: Application) {
var genres = mutableListOf<Genre>() var genres = mutableListOf<Genre>()
var artists = mutableListOf<Artist>()
var albums = mutableListOf<Album>() var albums = mutableListOf<Album>()
var songs = mutableListOf<Song>() var songs = mutableListOf<Song>()

View file

@ -78,11 +78,7 @@ class CompactPlaybackFragment : Fragment() {
playbackModel.disableAnimation() playbackModel.disableAnimation()
playbackModel.isPlaying.observe(viewLifecycleOwner) { playbackModel.isPlaying.observe(viewLifecycleOwner) {
if (it) { binding.playbackPlayPause.setPlaying(it, playbackModel.canAnimate)
binding.playbackPlayPause.showPause(playbackModel.canAnimate)
} else {
binding.playbackPlayPause.showPlay(playbackModel.canAnimate)
}
playbackModel.enableAnimation() playbackModel.enableAnimation()
} }

View file

@ -27,22 +27,22 @@ class PlayPauseButton @JvmOverloads constructor(
} }
} }
fun showPlay(animated: Boolean) { fun setPlaying(isPlaying: Boolean, animate: Boolean) {
if (animated) { if (isPlaying) {
if (animate) {
setImageDrawable(iconPlayToPause)
iconPlayToPause.start()
} else {
setImageResource(R.drawable.ic_pause_large)
}
} else {
if (animate) {
setImageDrawable(iconPauseToPlay) setImageDrawable(iconPauseToPlay)
iconPauseToPlay.start() iconPauseToPlay.start()
} else { } else {
setImageResource(R.drawable.ic_play_large) setImageResource(R.drawable.ic_play_large)
} }
} }
fun showPause(animated: Boolean) {
if (animated) {
setImageDrawable(iconPlayToPause)
iconPlayToPause.start()
} else {
setImageResource(R.drawable.ic_pause_large)
}
} }
/** /**

View file

@ -7,7 +7,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.SeekBar import android.widget.SeekBar
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
@ -186,12 +185,9 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
playbackModel.disableAnimation() playbackModel.disableAnimation()
playbackModel.isPlaying.observe(viewLifecycleOwner) { playbackModel.isPlaying.observe(viewLifecycleOwner) {
if (it) { binding.playbackPlayPause.apply {
binding.playbackPlayPause.showPause(playbackModel.canAnimate) backgroundTintList = if (it) accentColor else controlColor
binding.playbackPlayPause.backgroundTintList = accentColor setPlaying(it, playbackModel.canAnimate)
} else {
binding.playbackPlayPause.showPlay(playbackModel.canAnimate)
binding.playbackPlayPause.backgroundTintList = controlColor
} }
playbackModel.enableAnimation() playbackModel.enableAnimation()

View file

@ -514,10 +514,6 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
stopForegroundAndNotification() stopForegroundAndNotification()
} }
Intent.ACTION_VIEW -> {
logD("wat this works")
}
// --- HEADSET CASES --- // --- HEADSET CASES ---
BluetoothDevice.ACTION_ACL_CONNECTED -> resumeFromPlug() BluetoothDevice.ACTION_ACL_CONNECTED -> resumeFromPlug()

View file

@ -18,9 +18,7 @@ import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes import androidx.annotation.PluralsRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<data> <data>

View file

@ -8,7 +8,6 @@
<!-- Label Namespace | Static Labels --> <!-- Label Namespace | Static Labels -->
<string name="label_retry">Retry</string> <string name="label_retry">Retry</string>
<string name="label_grant">Grant</string> <string name="label_grant">Grant</string>
<string name="label_view_trace">View Error</string>
<string name="label_library">Library</string> <string name="label_library">Library</string>
<string name="label_genres">Genres</string> <string name="label_genres">Genres</string>