Browse Source

Fixed issue with merging around favorite management.

housekeeping/remove-warnings
Antoine POPINEAU 5 years ago
parent
commit
b7db24ea11
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 8
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 3
      app/src/main/java/com/github/apognu/otter/adapters/TracksAdapter.kt
  3. 10
      app/src/main/java/com/github/apognu/otter/fragments/QueueFragment.kt
  4. 5
      app/src/main/java/com/github/apognu/otter/repositories/TracksRepository.kt

8
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -314,9 +314,7 @@ class MainActivity : AppCompatActivity() { @@ -314,9 +314,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
now_playing_details_favorite?.let { now_playing_details_favorite ->
now_playing_details_favorite.setOnClickListener {
when (track.favorite) {
true -> {
@ -329,11 +327,11 @@ class MainActivity : AppCompatActivity() { @@ -329,11 +327,11 @@ class MainActivity : AppCompatActivity() {
now_playing_details_favorite.setColorFilter(getColor(R.color.colorFavorite))
}
}
}
track.favorite = !track.favorite
track.favorite = !track.favorite
favoriteRepository.fetch(Repository.Origin.Network.origin)
favoriteRepository.fetch(Repository.Origin.Network.origin)
}
}
}
}

3
app/src/main/java/com/github/apognu/otter/adapters/TracksAdapter.kt

@ -55,8 +55,6 @@ class TracksAdapter(private val context: Context?, private val favoriteListener: @@ -55,8 +55,6 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val track = data[position]
log("Bind ${track.favorite}")
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album.cover.original))
.fit()
@ -144,6 +142,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener: @@ -144,6 +142,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
}
notifyItemMoved(oldPosition, newPosition)
CommandBus.send(Command.MoveFromQueue(oldPosition, newPosition))
}

10
app/src/main/java/com/github/apognu/otter/fragments/QueueFragment.kt

@ -50,12 +50,8 @@ class QueueFragment : BottomSheetDialogFragment() { @@ -50,12 +50,8 @@ class QueueFragment : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_queue, container, false).apply {
adapter = TracksAdapter(context, FavoriteListener(), fromQueue = true).also {
queue.layoutManager = LinearLayoutManager(context)
queue.adapter = it
adapter = TracksAdapter(context, fromQueue = true).also {
included.queue.layoutManager = LinearLayoutManager(context)
included.queue.adapter = it
}
included.queue.layoutManager = LinearLayoutManager(context)
included.queue.adapter = it
}
}
}
@ -72,7 +68,7 @@ class QueueFragment : BottomSheetDialogFragment() { @@ -72,7 +68,7 @@ class QueueFragment : BottomSheetDialogFragment() {
private fun refresh() {
GlobalScope.launch(Main) {
RequestBus.send(Request.GetQueue).wait<Response.Queue>()?.let { response ->
included?.let {
included?.let { included ->
adapter?.let {
it.data = response.queue.toMutableList()
it.notifyDataSetChanged()

5
app/src/main/java/com/github/apognu/otter/repositories/TracksRepository.kt

@ -1,10 +1,7 @@ @@ -1,10 +1,7 @@
package com.github.apognu.otter.repositories
import android.content.Context
import com.github.apognu.otter.utils.FunkwhaleResponse
import com.github.apognu.otter.utils.Track
import com.github.apognu.otter.utils.TracksCache
import com.github.apognu.otter.utils.TracksResponse
import com.github.apognu.otter.utils.*
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.flow.map

Loading…
Cancel
Save