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