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.BaseModel
import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.MusicStore
import org.oxycblt.auxio.recycler.SortMode
/**
@ -41,8 +40,6 @@ class DetailViewModel : ViewModel() {
private val mNavToItem = MutableLiveData<BaseModel?>()
val navToItem: LiveData<BaseModel?> get() = mNavToItem
private val musicStore = MusicStore.getInstance()
/**
* Update the current navigation status
* @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
* 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
* quirk is immortalized and has to be replicated in all future iterations of the API!
* Yay! I hate this platform so much.
* quirk is immortalized and has to be replicated in all future iterations of this API! Yay!
*
* I hate this platform so much.
*/
genres.forEach { genre ->
val songCursor = resolver.query(

View file

@ -10,18 +10,16 @@ import androidx.core.database.getStringOrNull
import org.oxycblt.auxio.R
import org.oxycblt.auxio.logD
import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.music.toAlbumArtURI
/**
* 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) {
var genres = mutableListOf<Genre>()
var artists = mutableListOf<Artist>()
var albums = mutableListOf<Album>()
var songs = mutableListOf<Song>()

View file

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

View file

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

View file

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

View file

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

View file

@ -18,9 +18,7 @@ import android.widget.TextView
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
@ -107,7 +105,7 @@ fun Int.toStateList(context: Context) = ColorStateList.valueOf(toColor(context))
/**
* Resolve a drawable resource into a [Drawable]
*/
fun Int.toDrawable(context: Context) = ContextCompat.getDrawable(context, this)
fun Int.toDrawable(context: Context) = ContextCompat.getDrawable(context, this)
/**
* Resolve a drawable resource into an [AnimatedVectorDrawable]

View file

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

View file

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