Browse Source

Format code and fixed favoriting issue on favorite tab.

housekeeping/remove-warnings
Antoine POPINEAU 5 years ago
parent
commit
a55986343f
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 2
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  2. 11
      app/src/main/java/com/github/apognu/otter/fragments/FavoritesFragment.kt
  3. 3
      app/src/main/java/com/github/apognu/otter/fragments/FunkwhaleFragment.kt
  4. 5
      app/src/main/java/com/github/apognu/otter/repositories/TracksRepository.kt
  5. 1
      app/src/main/java/com/github/apognu/otter/utils/AppContext.kt
  6. 3
      app/src/main/java/com/github/apognu/otter/utils/EventBus.kt

2
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -18,12 +18,10 @@ import com.github.apognu.otter.repositories.AlbumsRepository @@ -18,12 +18,10 @@ import com.github.apognu.otter.repositories.AlbumsRepository
import com.github.apognu.otter.utils.*
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.fragment_albums.*
import kotlinx.android.synthetic.main.partial_now_playing.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.math.min
class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
override val viewRes = R.layout.fragment_albums

11
app/src/main/java/com/github/apognu/otter/fragments/FavoritesFragment.kt

@ -16,8 +16,6 @@ class FavoritesFragment : FunkwhaleFragment<Track, FavoritesAdapter>() { @@ -16,8 +16,6 @@ class FavoritesFragment : FunkwhaleFragment<Track, FavoritesAdapter>() {
override val viewRes = R.layout.fragment_favorites
override val recycler: RecyclerView get() = favorites
lateinit var favoritesRepository: FavoritesRepository
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -61,11 +59,12 @@ class FavoritesFragment : FunkwhaleFragment<Track, FavoritesAdapter>() { @@ -61,11 +59,12 @@ class FavoritesFragment : FunkwhaleFragment<Track, FavoritesAdapter>() {
inner class FavoriteListener : FavoritesAdapter.OnFavoriteListener {
override fun onToggleFavorite(id: Int, state: Boolean) {
when (state) {
true -> favoritesRepository.addFavorite(id)
false -> favoritesRepository.deleteFavorite(id)
(repository as? FavoritesRepository)?.let { repository ->
when (state) {
true -> repository.addFavorite(id)
false -> repository.deleteFavorite(id)
}
}
}
}
}

3
app/src/main/java/com/github/apognu/otter/fragments/FunkwhaleFragment.kt

@ -102,7 +102,8 @@ abstract class FunkwhaleFragment<D : Any, A : FunkwhaleAdapter<D, *>> : Fragment @@ -102,7 +102,8 @@ abstract class FunkwhaleFragment<D : Any, A : FunkwhaleAdapter<D, *>> : Fragment
Gson().toJson(repository.cache(adapter.data)).toByteArray()
)
}
} catch (e: ConcurrentModificationException) {}
} catch (e: ConcurrentModificationException) {
}
}
}
}

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

@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
package com.github.apognu.otter.repositories
import android.content.Context
import com.github.apognu.otter.utils.*
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.kittinunf.fuel.gson.gsonDeserializerOf
import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.flow.map

1
app/src/main/java/com/github/apognu/otter/utils/AppContext.kt

@ -7,7 +7,6 @@ import android.app.NotificationManager @@ -7,7 +7,6 @@ import android.app.NotificationManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.os.Build
import com.github.apognu.otter.R
import com.github.kittinunf.fuel.core.FuelManager

3
app/src/main/java/com/github/apognu/otter/utils/EventBus.kt

@ -4,9 +4,6 @@ import com.github.apognu.otter.Otter @@ -4,9 +4,6 @@ import com.github.apognu.otter.Otter
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.filter
import kotlinx.coroutines.channels.map
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch

Loading…
Cancel
Save