Fixed incorrect app context usage
This commit is contained in:
parent
fc5f3adcd9
commit
ee8deedd76
4 changed files with 12 additions and 11 deletions
|
@ -399,7 +399,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
if (hide) {
|
||||
bottomSheetBehavior.peekHeight = -windowInsets.safeGetBottomInsets()
|
||||
bottomSheetBehavior.state = STATE_COLLAPSED
|
||||
libraryViewModel.setFabMargin(if (isBottomNavVisible) dip(R.dimen.bottom_nav_height) else 0)
|
||||
libraryViewModel.setFabMargin(this, if (isBottomNavVisible) dip(R.dimen.bottom_nav_height) else 0)
|
||||
} else {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
binding.slidingPanel.elevation = 0F
|
||||
|
@ -411,7 +411,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
} else {
|
||||
bottomSheetBehavior.peekHeight = heightOfBarWithTabs
|
||||
}
|
||||
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height_expanded))
|
||||
libraryViewModel.setFabMargin(this, dip(R.dimen.mini_player_height_expanded))
|
||||
} else {
|
||||
println("Details")
|
||||
if (animate) {
|
||||
|
@ -422,7 +422,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomSheetBehavior.peekHeight = heightOfBar
|
||||
binding.slidingPanel.bringToFront()
|
||||
}
|
||||
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height))
|
||||
libraryViewModel.setFabMargin(this, dip(R.dimen.mini_player_height))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
if (which == 0) {
|
||||
showCreateDialog(songs)
|
||||
} else {
|
||||
libraryViewModel.addToPlaylist(playlistNames[which], songs)
|
||||
libraryViewModel.addToPlaylist(requireContext(), playlistNames[which], songs)
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
) { _, _ ->
|
||||
val playlistName = playlistView.text.toString()
|
||||
if (!TextUtils.isEmpty(playlistName)) {
|
||||
libraryViewModel.addToPlaylist(playlistName, songs)
|
||||
libraryViewModel.addToPlaylist(requireContext(), playlistName, songs)
|
||||
} else {
|
||||
playlistContainer.error = "Playlist name can't be empty"
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.fragments
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.lifecycle.*
|
||||
|
@ -339,7 +340,7 @@ class LibraryViewModel(
|
|||
searchResults.value = emptyList()
|
||||
}
|
||||
|
||||
fun addToPlaylist(playlistName: String, songs: List<Song>) {
|
||||
fun addToPlaylist(context: Context, playlistName: String, songs: List<Song>) {
|
||||
viewModelScope.launch(IO) {
|
||||
val playlists = checkPlaylistExists(playlistName)
|
||||
if (playlists.isEmpty()) {
|
||||
|
@ -348,8 +349,8 @@ class LibraryViewModel(
|
|||
insertSongs(songs.map { it.toSongEntity(playlistId) })
|
||||
withContext(Main) {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext()
|
||||
context ,
|
||||
context
|
||||
.getString(R.string.playlist_created_sucessfully, playlistName),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
|
@ -365,7 +366,7 @@ class LibraryViewModel(
|
|||
forceReload(Playlists)
|
||||
withContext(Main) {
|
||||
Toast.makeText(
|
||||
App.getContext(), App.getContext().getString(
|
||||
context, context.getString(
|
||||
R.string.added_song_count_to_playlist,
|
||||
songs.size,
|
||||
playlistName
|
||||
|
@ -375,8 +376,8 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun setFabMargin(bottomMargin: Int) {
|
||||
val currentValue = DensityUtil.dip2px(App.getContext(), 16F) +
|
||||
fun setFabMargin(context: Context, bottomMargin: Int) {
|
||||
val currentValue = DensityUtil.dip2px(context, 16F) +
|
||||
bottomMargin
|
||||
ValueAnimator.ofInt(fabMargin.value!!, currentValue).apply {
|
||||
addUpdateListener {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue