Browse Source

Minor adjustments to get rid of deprecation warnings

deploy-in-docker
Ryan Harg 3 years ago
parent
commit
ea286c2345
No known key found for this signature in database
GPG Key ID: 89106F3A84E6958C
  1. 2
      app/src/main/java/audio/funkwhale/ffa/adapters/FavoritesAdapter.kt
  2. 6
      app/src/main/java/audio/funkwhale/ffa/adapters/PlaylistTracksAdapter.kt
  3. 2
      app/src/main/java/audio/funkwhale/ffa/adapters/TracksAdapter.kt
  4. 35
      app/src/main/java/audio/funkwhale/ffa/fragments/PlaylistTracksFragment.kt
  5. 2
      app/src/main/java/audio/funkwhale/ffa/fragments/QueueFragment.kt
  6. 4
      app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt
  7. 10
      app/src/main/java/audio/funkwhale/ffa/utils/Util.kt

2
app/src/main/java/audio/funkwhale/ffa/adapters/FavoritesAdapter.kt

@ -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)
} }
} }

6
app/src/main/java/audio/funkwhale/ffa/adapters/PlaylistTracksAdapter.kt

@ -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
} }

2
app/src/main/java/audio/funkwhale/ffa/adapters/TracksAdapter.kt

@ -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))
} }
} }

35
app/src/main/java/audio/funkwhale/ffa/fragments/PlaylistTracksFragment.kt

@ -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.repositories.FavoritesRepository
import audio.funkwhale.ffa.repositories.ManagementPlaylistsRepository
import audio.funkwhale.ffa.repositories.PlaylistTracksRepository
import audio.funkwhale.ffa.utils.Command
import audio.funkwhale.ffa.utils.CommandBus
import audio.funkwhale.ffa.model.Playlist import audio.funkwhale.ffa.model.Playlist
import audio.funkwhale.ffa.model.PlaylistTrack 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.model.Track
import audio.funkwhale.ffa.utils.maybeLoad import audio.funkwhale.ffa.repositories.FavoritesRepository
import audio.funkwhale.ffa.utils.maybeNormalizeUrl import audio.funkwhale.ffa.repositories.ManagementPlaylistsRepository
import audio.funkwhale.ffa.utils.toast import audio.funkwhale.ffa.repositories.PlaylistTracksRepository
import audio.funkwhale.ffa.utils.wait import audio.funkwhale.ffa.utils.*
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()
} }
} }

2
app/src/main/java/audio/funkwhale/ffa/fragments/QueueFragment.kt

@ -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)

4
app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt

@ -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}")

10
app/src/main/java/audio/funkwhale/ffa/utils/Util.kt

@ -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)

Loading…
Cancel
Save