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
|
# 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,6 +129,7 @@ class AlbumDetailFragment : DetailFragment() {
|
||||||
playbackModel.navToItem.observe(viewLifecycleOwner) {
|
playbackModel.navToItem.observe(viewLifecycleOwner) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
/*
|
/*
|
||||||
|
if (it is Song) {
|
||||||
// Calculate where the item for the currently played song is, and navigate to there.
|
// Calculate where the item for the currently played song is, and navigate to there.
|
||||||
val pos = detailModel.albumSortMode.value!!.getSortedSongList(
|
val pos = detailModel.albumSortMode.value!!.getSortedSongList(
|
||||||
detailModel.currentAlbum.value!!.songs
|
detailModel.currentAlbum.value!!.songs
|
||||||
|
@ -145,11 +146,15 @@ class AlbumDetailFragment : DetailFragment() {
|
||||||
|
|
||||||
playbackModel.doneWithNavToItem()
|
playbackModel.doneWithNavToItem()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TODO: Re-add scroll if you find a way to implement the playing indicators on song items
|
TODO: Re-add scroll if you find a way to implement the playing indicators on song items
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (detailModel.currentAlbum.value!!.id == playbackModel.song.value!!.album.id) {
|
||||||
playbackModel.doneWithNavToItem()
|
playbackModel.doneWithNavToItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(this::class.simpleName, "Fragment created.")
|
Log.d(this::class.simpleName, "Fragment created.")
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||||
searchView.setOnQueryTextListener(this@LibraryFragment)
|
searchView.setOnQueryTextListener(this@LibraryFragment)
|
||||||
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
|
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
|
||||||
libraryModel.updateSearchFocusStatus(hasFocus)
|
libraryModel.updateSearchFocusStatus(hasFocus)
|
||||||
libraryModel.doSearch(searchView.query.toString(), requireContext())
|
|
||||||
item.isVisible = !hasFocus
|
item.isVisible = !hasFocus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +154,8 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
libraryModel.updateNavigationStatus(false)
|
libraryModel.updateNavigationStatus(false)
|
||||||
|
|
||||||
if (it is Song) {
|
if (it is Song || it is Album) {
|
||||||
navToItem(it.album)
|
navToItem(playbackModel.song.value!!.album)
|
||||||
} else {
|
} else {
|
||||||
navToItem(it)
|
navToItem(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,6 @@ import org.oxycblt.auxio.recycler.SortMode
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class LibraryViewModel : ViewModel() {
|
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
|
// TODO: Move these to prefs when they're added
|
||||||
private val mShowMode = MutableLiveData(ShowMode.SHOW_ARTISTS)
|
private val mShowMode = MutableLiveData(ShowMode.SHOW_ARTISTS)
|
||||||
val showMode: LiveData<ShowMode> get() = mShowMode
|
val showMode: LiveData<ShowMode> get() = mShowMode
|
||||||
|
@ -36,6 +30,12 @@ class LibraryViewModel : ViewModel() {
|
||||||
private val mSearchResults = MutableLiveData(listOf<BaseModel>())
|
private val mSearchResults = MutableLiveData(listOf<BaseModel>())
|
||||||
val searchResults: LiveData<List<BaseModel>> get() = mSearchResults
|
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.
|
* Perform a search of the music library, given a query.
|
||||||
* Results are pushed to [searchResults].
|
* Results are pushed to [searchResults].
|
||||||
|
|
|
@ -83,8 +83,6 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
||||||
queueMenuItem = menu.findItem(R.id.action_queue)
|
queueMenuItem = menu.findItem(R.id.action_queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make marquee scroll work
|
|
||||||
binding.playbackSong.isSelected = true
|
|
||||||
binding.playbackSeekBar.setOnSeekBarChangeListener(this)
|
binding.playbackSeekBar.setOnSeekBarChangeListener(this)
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP --
|
// --- VIEWMODEL SETUP --
|
||||||
|
|
|
@ -6,8 +6,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.music.Song
|
import org.oxycblt.auxio.music.Song
|
||||||
import org.oxycblt.auxio.recycler.viewholders.SongViewHolder
|
import org.oxycblt.auxio.recycler.viewholders.SongViewHolder
|
||||||
|
|
||||||
class SongAdapter(
|
class SongsAdapter(
|
||||||
val data: List<Song>,
|
private val data: List<Song>,
|
||||||
private val doOnClick: (data: Song) -> Unit,
|
private val doOnClick: (data: Song) -> Unit,
|
||||||
private val doOnLongClick: (data: Song, view: View) -> Unit
|
private val doOnLongClick: (data: Song, view: View) -> Unit
|
||||||
) : RecyclerView.Adapter<SongViewHolder>() {
|
) : RecyclerView.Adapter<SongViewHolder>() {
|
|
@ -38,7 +38,7 @@ class SongsFragment : Fragment() {
|
||||||
|
|
||||||
val musicStore = MusicStore.getInstance()
|
val musicStore = MusicStore.getInstance()
|
||||||
|
|
||||||
val songAdapter = SongAdapter(
|
val songAdapter = SongsAdapter(
|
||||||
musicStore.songs,
|
musicStore.songs,
|
||||||
doOnClick = { playbackModel.playSong(it, PlaybackMode.ALL_SONGS) },
|
doOnClick = { playbackModel.playSong(it, PlaybackMode.ALL_SONGS) },
|
||||||
doOnLongClick = { data, view ->
|
doOnLongClick = { data, view ->
|
||||||
|
@ -48,8 +48,6 @@ class SongsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Add option to search songs [Or just make a dedicated tab]
|
|
||||||
|
|
||||||
// --- UI SETUP ---
|
// --- UI SETUP ---
|
||||||
|
|
||||||
binding.songToolbar.setOnMenuItemClickListener {
|
binding.songToolbar.setOnMenuItemClickListener {
|
||||||
|
@ -64,6 +62,16 @@ class SongsFragment : Fragment() {
|
||||||
setHasFixedSize(true)
|
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 {
|
binding.songFastScroll.apply {
|
||||||
var hasAddedNumber = false
|
var hasAddedNumber = false
|
||||||
var iters = 0
|
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.")
|
binding.songFastScrollThumb.apply {
|
||||||
|
setupWithFastScroller(binding.songFastScroll)
|
||||||
return binding.root
|
textAppearanceRes = R.style.TextAppearance_ThumbIndicator
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
android:id="@+id/action_shuffle"
|
android:id="@+id/action_shuffle"
|
||||||
android:icon="@drawable/ic_shuffle"
|
android:icon="@drawable/ic_shuffle"
|
||||||
android:title="@string/label_shuffle"
|
android:title="@string/label_shuffle"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="ifRoom" />
|
||||||
</menu>
|
</menu>
|
|
@ -11,24 +11,24 @@
|
||||||
tools:layout="@layout/fragment_library">
|
tools:layout="@layout/fragment_library">
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_genre"
|
android:id="@+id/action_show_genre"
|
||||||
app:enterAnim="@animator/nav_default_enter_anim"
|
app:enterAnim="@anim/nav_default_enter_anim"
|
||||||
app:exitAnim="@animator/nav_default_exit_anim"
|
app:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/genre_detail_fragment" />
|
app:destination="@id/genre_detail_fragment" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_artist"
|
android:id="@+id/action_show_artist"
|
||||||
app:enterAnim="@animator/nav_default_enter_anim"
|
app:enterAnim="@anim/nav_default_enter_anim"
|
||||||
app:exitAnim="@animator/nav_default_exit_anim"
|
app:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/artist_detail_fragment" />
|
app:destination="@id/artist_detail_fragment" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_album"
|
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:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/album_detail_fragment" />
|
app:destination="@id/album_detail_fragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
|
@ -41,10 +41,10 @@
|
||||||
app:argType="long" />
|
app:argType="long" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_album"
|
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:exitAnim="@animator/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/album_detail_fragment"
|
app:destination="@id/album_detail_fragment"
|
||||||
app:launchSingleTop="true" />
|
app:launchSingleTop="true" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
@ -61,10 +61,10 @@
|
||||||
app:argType="boolean" />
|
app:argType="boolean" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_parent_artist"
|
android:id="@+id/action_show_parent_artist"
|
||||||
app:enterAnim="@animator/nav_default_enter_anim"
|
app:enterAnim="@anim/nav_default_enter_anim"
|
||||||
app:exitAnim="@animator/nav_default_exit_anim"
|
app:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/artist_detail_fragment" />
|
app:destination="@id/artist_detail_fragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
|
@ -74,10 +74,10 @@
|
||||||
tools:layout="@layout/fragment_genre_detail">
|
tools:layout="@layout/fragment_genre_detail">
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_show_artist"
|
android:id="@+id/action_show_artist"
|
||||||
app:enterAnim="@animator/nav_default_enter_anim"
|
app:enterAnim="@anim/nav_default_enter_anim"
|
||||||
app:exitAnim="@animator/nav_default_exit_anim"
|
app:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:destination="@id/artist_detail_fragment" />
|
app:destination="@id/artist_detail_fragment" />
|
||||||
<argument
|
<argument
|
||||||
android:name="genreId"
|
android:name="genreId"
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_to_main"
|
android:id="@+id/action_to_main"
|
||||||
app:destination="@id/main_fragment"
|
app:destination="@id/main_fragment"
|
||||||
app:enterAnim="@animator/nav_default_enter_anim"
|
app:enterAnim="@anim/nav_default_enter_anim"
|
||||||
app:exitAnim="@animator/nav_default_exit_anim"
|
app:exitAnim="@anim/nav_default_exit_anim"
|
||||||
app:popEnterAnim="@animator/nav_default_pop_enter_anim"
|
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||||
app:popExitAnim="@animator/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:popUpTo="@id/loading_fragment"
|
app:popUpTo="@id/loading_fragment"
|
||||||
app:popUpToInclusive="true"
|
app:popUpToInclusive="true"
|
||||||
app:launchSingleTop="true" />
|
app:launchSingleTop="true" />
|
||||||
|
|
Loading…
Reference in a new issue