Browse Source

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

Minor adjustments to get rid of deprecation warnings

See merge request funkwhale/funkwhale-android!79
deploy-in-docker
Ryan Harg 3 years ago
parent
commit
1ac1424cb2
  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. 23
      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( @@ -106,7 +106,7 @@ class FavoritesAdapter(
favoriteListener.onToggleFavorite(favorite.id, !favorite.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( @@ -199,10 +199,10 @@ class PlaylistTracksAdapter(
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
if (from == -1) from = viewHolder.adapterPosition
to = target.adapterPosition
if (from == -1) from = viewHolder.bindingAdapterPosition
to = target.bindingAdapterPosition
onItemMove(viewHolder.adapterPosition, target.adapterPosition)
onItemMove(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition)
return true
}

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

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

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

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

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

@ -78,7 +78,7 @@ class QueueFragment : BottomSheetDialogFragment() { @@ -78,7 +78,7 @@ class QueueFragment : BottomSheetDialogFragment() {
super.onResume()
binding.included.queue.visibility = View.GONE
binding.included.placeholder?.visibility = View.VISIBLE
binding.included.placeholder.visibility = View.VISIBLE
binding.included.queueShuffle.setOnClickListener {
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?) : @@ -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 {
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()) {
authorize(context, oAuth)
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 @@ -3,8 +3,6 @@ package audio.funkwhale.ffa.utils
import android.content.Context
import android.widget.Toast
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 java.net.URI
@ -33,10 +31,10 @@ private fun logClassName(): String { @@ -33,10 +31,10 @@ private fun logClassName(): String {
return "UNKNOWN"
}
enum class LogLevel(value: Int) {
INFO(LOG_LEVEL_INFO),
DEBUG(Log.LOG_LEVEL_ALL),
ERROR(LOG_LEVEL_ERROR)
enum class LogLevel {
INFO,
DEBUG,
ERROR
}
fun Any?.logError(prefix: String? = null) = this.log(prefix, LogLevel.ERROR)

Loading…
Cancel
Save