Remove usages of animator to fix nav bugs
Remove usages of animator as apparently sometimes that actually causes bugs. Why do I do this to myself.
This commit is contained in:
parent
3fca28dd20
commit
1af17a6df1
10 changed files with 76 additions and 65 deletions
|
@ -1,2 +1,5 @@
|
|||
# Auxio
|
||||
Android Music Player, Current WIP
|
||||
|
||||
Auxio is a music player for android that I built for myself. It only has the features that I need out of a music player and nothing more.
|
||||
|
||||
***WIP***
|
||||
|
|
|
@ -129,25 +129,30 @@ class AlbumDetailFragment : DetailFragment() {
|
|||
playbackModel.navToItem.observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
/*
|
||||
// Calculate where the item for the currently played song is, and navigate to there.
|
||||
val pos = detailModel.albumSortMode.value!!.getSortedSongList(
|
||||
detailModel.currentAlbum.value!!.songs
|
||||
).indexOf(playbackModel.song.value)
|
||||
if (it is Song) {
|
||||
// Calculate where the item for the currently played song is, and navigate to there.
|
||||
val pos = detailModel.albumSortMode.value!!.getSortedSongList(
|
||||
detailModel.currentAlbum.value!!.songs
|
||||
).indexOf(playbackModel.song.value)
|
||||
|
||||
if (pos != -1) {
|
||||
binding.albumSongRecycler.post {
|
||||
// Only scroll after UI creation
|
||||
val y = binding.albumSongRecycler.y +
|
||||
binding.albumSongRecycler.getChildAt(pos).y
|
||||
if (pos != -1) {
|
||||
binding.albumSongRecycler.post {
|
||||
// Only scroll after UI creation
|
||||
val y = binding.albumSongRecycler.y +
|
||||
binding.albumSongRecycler.getChildAt(pos).y
|
||||
|
||||
binding.nestedScroll.scrollTo(0, y.toInt())
|
||||
binding.nestedScroll.scrollTo(0, y.toInt())
|
||||
}
|
||||
|
||||
playbackModel.doneWithNavToItem()
|
||||
}
|
||||
|
||||
playbackModel.doneWithNavToItem()
|
||||
}
|
||||
TODO: Re-add scroll if you find a way to implement the playing indicators on song items
|
||||
*/
|
||||
playbackModel.doneWithNavToItem()
|
||||
*/
|
||||
|
||||
if (detailModel.currentAlbum.value!!.id == playbackModel.song.value!!.album.id) {
|
||||
playbackModel.doneWithNavToItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
|||
searchView.setOnQueryTextListener(this@LibraryFragment)
|
||||
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
|
||||
libraryModel.updateSearchFocusStatus(hasFocus)
|
||||
libraryModel.doSearch(searchView.query.toString(), requireContext())
|
||||
item.isVisible = !hasFocus
|
||||
}
|
||||
|
||||
|
@ -155,8 +154,8 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
|||
if (it != null) {
|
||||
libraryModel.updateNavigationStatus(false)
|
||||
|
||||
if (it is Song) {
|
||||
navToItem(it.album)
|
||||
if (it is Song || it is Album) {
|
||||
navToItem(playbackModel.song.value!!.album)
|
||||
} else {
|
||||
navToItem(it)
|
||||
}
|
||||
|
|
|
@ -20,12 +20,6 @@ import org.oxycblt.auxio.recycler.SortMode
|
|||
* @author OxygenCobalt
|
||||
*/
|
||||
class LibraryViewModel : ViewModel() {
|
||||
private var mIsNavigating = false
|
||||
val isNavigating: Boolean get() = mIsNavigating
|
||||
|
||||
private var mSearchHasFocus = false
|
||||
val searchHasFocus: Boolean get() = mSearchHasFocus
|
||||
|
||||
// TODO: Move these to prefs when they're added
|
||||
private val mShowMode = MutableLiveData(ShowMode.SHOW_ARTISTS)
|
||||
val showMode: LiveData<ShowMode> get() = mShowMode
|
||||
|
@ -36,6 +30,12 @@ class LibraryViewModel : ViewModel() {
|
|||
private val mSearchResults = MutableLiveData(listOf<BaseModel>())
|
||||
val searchResults: LiveData<List<BaseModel>> get() = mSearchResults
|
||||
|
||||
private var mIsNavigating = false
|
||||
val isNavigating: Boolean get() = mIsNavigating
|
||||
|
||||
private var mSearchHasFocus = false
|
||||
val searchHasFocus: Boolean get() = mSearchHasFocus
|
||||
|
||||
/**
|
||||
* Perform a search of the music library, given a query.
|
||||
* Results are pushed to [searchResults].
|
||||
|
|
|
@ -83,8 +83,6 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
|||
queueMenuItem = menu.findItem(R.id.action_queue)
|
||||
}
|
||||
|
||||
// Make marquee scroll work
|
||||
binding.playbackSong.isSelected = true
|
||||
binding.playbackSeekBar.setOnSeekBarChangeListener(this)
|
||||
|
||||
// --- VIEWMODEL SETUP --
|
||||
|
|
|
@ -6,8 +6,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import org.oxycblt.auxio.music.Song
|
||||
import org.oxycblt.auxio.recycler.viewholders.SongViewHolder
|
||||
|
||||
class SongAdapter(
|
||||
val data: List<Song>,
|
||||
class SongsAdapter(
|
||||
private val data: List<Song>,
|
||||
private val doOnClick: (data: Song) -> Unit,
|
||||
private val doOnLongClick: (data: Song, view: View) -> Unit
|
||||
) : RecyclerView.Adapter<SongViewHolder>() {
|
|
@ -38,7 +38,7 @@ class SongsFragment : Fragment() {
|
|||
|
||||
val musicStore = MusicStore.getInstance()
|
||||
|
||||
val songAdapter = SongAdapter(
|
||||
val songAdapter = SongsAdapter(
|
||||
musicStore.songs,
|
||||
doOnClick = { playbackModel.playSong(it, PlaybackMode.ALL_SONGS) },
|
||||
doOnLongClick = { data, view ->
|
||||
|
@ -48,8 +48,6 @@ class SongsFragment : Fragment() {
|
|||
}
|
||||
)
|
||||
|
||||
// TODO: Add option to search songs [Or just make a dedicated tab]
|
||||
|
||||
// --- UI SETUP ---
|
||||
|
||||
binding.songToolbar.setOnMenuItemClickListener {
|
||||
|
@ -64,6 +62,16 @@ class SongsFragment : Fragment() {
|
|||
setHasFixedSize(true)
|
||||
}
|
||||
|
||||
setupFastScroller(binding)
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun setupFastScroller(binding: FragmentSongsBinding) {
|
||||
val musicStore = MusicStore.getInstance()
|
||||
|
||||
binding.songFastScroll.apply {
|
||||
var hasAddedNumber = false
|
||||
var iters = 0
|
||||
|
@ -126,13 +134,11 @@ class SongsFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.songFastScrollThumb.setupWithFastScroller(this)
|
||||
binding.songFastScrollThumb.textAppearanceRes = R.style.TextAppearance_ThumbIndicator
|
||||
}
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
binding.songFastScrollThumb.apply {
|
||||
setupWithFastScroller(binding.songFastScroll)
|
||||
textAppearanceRes = R.style.TextAppearance_ThumbIndicator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
android:id="@+id/action_shuffle"
|
||||
android:icon="@drawable/ic_shuffle"
|
||||
android:title="@string/label_shuffle"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
|
@ -11,24 +11,24 @@
|
|||
tools:layout="@layout/fragment_library">
|
||||
<action
|
||||
android:id="@+id/action_show_genre"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/genre_detail_fragment" />
|
||||
<action
|
||||
android:id="@+id/action_show_artist"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/artist_detail_fragment" />
|
||||
<action
|
||||
android:id="@+id/action_show_album"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/album_detail_fragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
|
@ -41,10 +41,10 @@
|
|||
app:argType="long" />
|
||||
<action
|
||||
android:id="@+id/action_show_album"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/album_detail_fragment"
|
||||
app:launchSingleTop="true" />
|
||||
</fragment>
|
||||
|
@ -61,10 +61,10 @@
|
|||
app:argType="boolean" />
|
||||
<action
|
||||
android:id="@+id/action_show_parent_artist"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/artist_detail_fragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
|
@ -74,10 +74,10 @@
|
|||
tools:layout="@layout/fragment_genre_detail">
|
||||
<action
|
||||
android:id="@+id/action_show_artist"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:destination="@id/artist_detail_fragment" />
|
||||
<argument
|
||||
android:name="genreId"
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
<action
|
||||
android:id="@+id/action_to_main"
|
||||
app:destination="@id/main_fragment"
|
||||
app:enterAnim="@animator/nav_default_enter_anim"
|
||||
app:exitAnim="@animator/nav_default_exit_anim"
|
||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:popUpTo="@id/loading_fragment"
|
||||
app:popUpToInclusive="true"
|
||||
app:launchSingleTop="true" />
|
||||
|
|
Loading…
Reference in a new issue