Fixed issue with merging around favorite management.

This commit is contained in:
Antoine POPINEAU 2019-11-22 20:14:05 +01:00
parent 40117122c7
commit b7db24ea11
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
4 changed files with 9 additions and 19 deletions

View File

@ -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() {
now_playing_details_favorite.setColorFilter(getColor(R.color.colorFavorite))
}
}
track.favorite = !track.favorite
favoriteRepository.fetch(Repository.Origin.Network.origin)
}
track.favorite = !track.favorite
favoriteRepository.fetch(Repository.Origin.Network.origin)
}
}
}

View File

@ -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:
}
notifyItemMoved(oldPosition, newPosition)
CommandBus.send(Command.MoveFromQueue(oldPosition, newPosition))
}

View File

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

View File

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