Merge branch 'housekeeping/remove-deprecation-warnings' into 'develop'

Minor adjustments to get rid of deprecation warnings

See merge request funkwhale/funkwhale-android!79
This commit is contained in:
Ryan Harg 2021-08-27 11:35:17 +00:00
commit 1ac1424cb2
7 changed files with 25 additions and 36 deletions

View File

@ -106,7 +106,7 @@ class FavoritesAdapter(
favoriteListener.onToggleFavorite(favorite.id, !favorite.favorite) favoriteListener.onToggleFavorite(favorite.id, !favorite.favorite)
data.remove(favorite) data.remove(favorite)
notifyItemRemoved(holder.adapterPosition) notifyItemRemoved(holder.bindingAdapterPosition)
} }
} }

View File

@ -199,10 +199,10 @@ class PlaylistTracksAdapter(
viewHolder: RecyclerView.ViewHolder, viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder target: RecyclerView.ViewHolder
): Boolean { ): Boolean {
if (from == -1) from = viewHolder.adapterPosition if (from == -1) from = viewHolder.bindingAdapterPosition
to = target.adapterPosition to = target.bindingAdapterPosition
onItemMove(viewHolder.adapterPosition, target.adapterPosition) onItemMove(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition)
return true return true
} }

View File

@ -230,7 +230,7 @@ class TracksAdapter(
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
context?.let { context?.let {
viewHolder?.let { viewHolder?.let {
from = viewHolder.adapterPosition from = viewHolder.bindingAdapterPosition
viewHolder.itemView.background = ColorDrawable(context.getColor(R.color.colorSelected)) viewHolder.itemView.background = ColorDrawable(context.getColor(R.color.colorSelected))
} }
} }

View File

@ -12,21 +12,13 @@ import androidx.recyclerview.widget.RecyclerView
import audio.funkwhale.ffa.R import audio.funkwhale.ffa.R
import audio.funkwhale.ffa.adapters.PlaylistTracksAdapter import audio.funkwhale.ffa.adapters.PlaylistTracksAdapter
import audio.funkwhale.ffa.databinding.FragmentTracksBinding import audio.funkwhale.ffa.databinding.FragmentTracksBinding
import audio.funkwhale.ffa.model.Playlist
import audio.funkwhale.ffa.model.PlaylistTrack
import audio.funkwhale.ffa.model.Track
import audio.funkwhale.ffa.repositories.FavoritesRepository import audio.funkwhale.ffa.repositories.FavoritesRepository
import audio.funkwhale.ffa.repositories.ManagementPlaylistsRepository import audio.funkwhale.ffa.repositories.ManagementPlaylistsRepository
import audio.funkwhale.ffa.repositories.PlaylistTracksRepository import audio.funkwhale.ffa.repositories.PlaylistTracksRepository
import audio.funkwhale.ffa.utils.Command import audio.funkwhale.ffa.utils.*
import audio.funkwhale.ffa.utils.CommandBus
import audio.funkwhale.ffa.model.Playlist
import audio.funkwhale.ffa.model.PlaylistTrack
import audio.funkwhale.ffa.utils.Request
import audio.funkwhale.ffa.utils.RequestBus
import audio.funkwhale.ffa.utils.Response
import audio.funkwhale.ffa.model.Track
import audio.funkwhale.ffa.utils.maybeLoad
import audio.funkwhale.ffa.utils.maybeNormalizeUrl
import audio.funkwhale.ffa.utils.toast
import audio.funkwhale.ffa.utils.wait
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
@ -183,15 +175,14 @@ class PlaylistTracksFragment : FFAFragment<PlaylistTrack, PlaylistTracksAdapter>
else -> RoundedCornersTransformation.CornerType.TOP_LEFT else -> RoundedCornersTransformation.CornerType.TOP_LEFT
} }
imageView?.let { view ->
lifecycleScope.launch(Main) { lifecycleScope.launch(Main) {
Picasso.get() Picasso.get()
.maybeLoad(maybeNormalizeUrl(url)) .maybeLoad(maybeNormalizeUrl(url))
.fit() .fit()
.centerCrop() .centerCrop()
.transform(RoundedCornersTransformation(16, 0, corner)) .transform(RoundedCornersTransformation(16, 0, corner))
.into(view) .into(imageView)
}
} }
} }
} }
@ -229,7 +220,7 @@ class PlaylistTracksFragment : FFAFragment<PlaylistTrack, PlaylistTracksAdapter>
override fun onRemoveTrackFromPlaylist(track: Track, index: Int) { override fun onRemoveTrackFromPlaylist(track: Track, index: Int) {
lifecycleScope.launch(Main) { lifecycleScope.launch(Main) {
playlistsRepository.remove(albumId, track, index) playlistsRepository.remove(albumId, index)
update() update()
} }
} }

View File

@ -78,7 +78,7 @@ class QueueFragment : BottomSheetDialogFragment() {
super.onResume() super.onResume()
binding.included.queue.visibility = View.GONE binding.included.queue.visibility = View.GONE
binding.included.placeholder?.visibility = View.VISIBLE binding.included.placeholder.visibility = View.VISIBLE
binding.included.queueShuffle.setOnClickListener { binding.included.queueShuffle.setOnClickListener {
CommandBus.send(Command.ShuffleQueue) CommandBus.send(Command.ShuffleQueue)

View File

@ -103,11 +103,11 @@ class ManagementPlaylistsRepository(override val context: Context?) :
} }
} }
suspend fun remove(id: Int, track: Track, index: Int) { suspend fun remove(albumId: Int, index: Int) {
context?.let { context?.let {
val body = mapOf("index" to index) val body = mapOf("index" to index)
val request = Fuel.post(mustNormalizeUrl("/api/v1/playlists/$id/remove/")).apply { val request = Fuel.post(mustNormalizeUrl("/api/v1/playlists/$albumId/remove/")).apply {
if (!Settings.isAnonymous()) { if (!Settings.isAnonymous()) {
authorize(context, oAuth) authorize(context, oAuth)
header("Authorization", "Bearer ${oAuth.state().accessToken}") header("Authorization", "Bearer ${oAuth.state().accessToken}")

View File

@ -3,8 +3,6 @@ package audio.funkwhale.ffa.utils
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast
import com.google.android.exoplayer2.util.Log import com.google.android.exoplayer2.util.Log
import com.google.android.exoplayer2.util.Log.LOG_LEVEL_ERROR
import com.google.android.exoplayer2.util.Log.LOG_LEVEL_INFO
import com.preference.PowerPreference import com.preference.PowerPreference
import java.net.URI import java.net.URI
@ -33,10 +31,10 @@ private fun logClassName(): String {
return "UNKNOWN" return "UNKNOWN"
} }
enum class LogLevel(value: Int) { enum class LogLevel {
INFO(LOG_LEVEL_INFO), INFO,
DEBUG(Log.LOG_LEVEL_ALL), DEBUG,
ERROR(LOG_LEVEL_ERROR) ERROR
} }
fun Any?.logError(prefix: String? = null) = this.log(prefix, LogLevel.ERROR) fun Any?.logError(prefix: String? = null) = this.log(prefix, LogLevel.ERROR)