Minor enhancements to home screen.
This commit is contained in:
parent
2e76d30e0f
commit
8356afecce
|
@ -33,7 +33,7 @@ class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : Fragm
|
||||||
|
|
||||||
override fun getPageTitle(position: Int): String {
|
override fun getPageTitle(position: Int): String {
|
||||||
return when (position) {
|
return when (position) {
|
||||||
0 -> "Otter"
|
0 -> context.getString(R.string.title_discover)
|
||||||
1 -> context.getString(R.string.artists)
|
1 -> context.getString(R.string.artists)
|
||||||
2 -> context.getString(R.string.albums)
|
2 -> context.getString(R.string.albums)
|
||||||
3 -> context.getString(R.string.playlists)
|
3 -> context.getString(R.string.playlists)
|
||||||
|
|
|
@ -92,7 +92,7 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
adapter = tagsAdapter
|
adapter = tagsAdapter
|
||||||
layoutManager = FlexboxLayoutManager(context).apply {
|
layoutManager = FlexboxLayoutManager(context).apply {
|
||||||
justifyContent = JustifyContent.SPACE_BETWEEN
|
justifyContent = JustifyContent.FLEX_START
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refresh(force: Boolean = false) {
|
private fun refresh(force: Boolean = false) {
|
||||||
tagsRepository.fetch(originFor(tagsRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _ ->
|
tagsRepository.fetch(originFor(tagsRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _, _ ->
|
||||||
GlobalScope.launch(Main) {
|
GlobalScope.launch(Main) {
|
||||||
tagsAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.name, null) }
|
tagsAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.name, null) }
|
||||||
tagsAdapter.notifyDataSetChanged()
|
tagsAdapter.notifyDataSetChanged()
|
||||||
|
@ -156,9 +156,9 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
randomArtistsRepository.fetch(originFor(randomArtistsRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _ ->
|
randomArtistsRepository.fetch(originFor(randomArtistsRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _, _ ->
|
||||||
GlobalScope.launch(Main) {
|
GlobalScope.launch(Main) {
|
||||||
randomAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.name, it.albums?.getOrNull(0)?.cover?.original, artist = it) }
|
randomAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.name, it.albums?.getOrNull(0)?.cover?.urls?.original, artist = it) }
|
||||||
randomAdapter.notifyDataSetChanged()
|
randomAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
random_loader?.visibility = View.GONE
|
random_loader?.visibility = View.GONE
|
||||||
|
@ -168,9 +168,9 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recentlyListenedRepository.fetch(originFor(recentlyListenedRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _ ->
|
recentlyListenedRepository.fetch(originFor(recentlyListenedRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _, _ ->
|
||||||
GlobalScope.launch(Main) {
|
GlobalScope.launch(Main) {
|
||||||
recentlyListenedAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.track.title, it.track.album.cover.original, track = it.track) }
|
recentlyListenedAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.track.title, it.track.album?.cover(), track = it.track) }
|
||||||
recentlyListenedAdapter.notifyDataSetChanged()
|
recentlyListenedAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
recently_listened_loader?.visibility = View.GONE
|
recently_listened_loader?.visibility = View.GONE
|
||||||
|
@ -180,9 +180,9 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recentlyAddedRepository.fetch(originFor(recentlyAddedRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _ ->
|
recentlyAddedRepository.fetch(originFor(recentlyAddedRepository, force).origin).untilNetwork(lifecycleScope, IO) { data, isCache, _, _ ->
|
||||||
GlobalScope.launch(Main) {
|
GlobalScope.launch(Main) {
|
||||||
recentlyAddedAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.title, it.album.cover.original, track = it) }
|
recentlyAddedAdapter.data = data.map { HomeMediaAdapter.HomeMediaItem(it.title, it.album?.cover(), track = it) }
|
||||||
recentlyAddedAdapter.notifyDataSetChanged()
|
recentlyAddedAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
recently_added_loader?.visibility = View.GONE
|
recently_added_loader?.visibility = View.GONE
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.github.apognu.otter.repositories.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.github.apognu.otter.repositories.HttpUpstream
|
import com.github.apognu.otter.repositories.HttpUpstream
|
||||||
import com.github.apognu.otter.repositories.Repository
|
import com.github.apognu.otter.repositories.Repository
|
||||||
import com.github.apognu.otter.utils.Artist
|
import com.github.apognu.otter.utils.*
|
||||||
import com.github.apognu.otter.utils.ArtistsCache
|
|
||||||
import com.github.apognu.otter.utils.ArtistsResponse
|
|
||||||
import com.github.apognu.otter.utils.FunkwhaleResponse
|
|
||||||
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -15,7 +12,7 @@ class RandomArtistsRepository(override val context: Context?) : Repository<Artis
|
||||||
override val cacheId = "home-random-artists"
|
override val cacheId = "home-random-artists"
|
||||||
|
|
||||||
override val upstream =
|
override val upstream =
|
||||||
HttpUpstream<Artist, FunkwhaleResponse<Artist>>(
|
HttpUpstream<Artist, OtterResponse<Artist>>(
|
||||||
HttpUpstream.Behavior.Single,
|
HttpUpstream.Behavior.Single,
|
||||||
"/api/v1/artists/?playable=true&ordering=random",
|
"/api/v1/artists/?playable=true&ordering=random",
|
||||||
object : TypeToken<ArtistsResponse>() {}.type,
|
object : TypeToken<ArtistsResponse>() {}.type,
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.github.apognu.otter.repositories.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.github.apognu.otter.repositories.HttpUpstream
|
import com.github.apognu.otter.repositories.HttpUpstream
|
||||||
import com.github.apognu.otter.repositories.Repository
|
import com.github.apognu.otter.repositories.Repository
|
||||||
import com.github.apognu.otter.utils.FunkwhaleResponse
|
import com.github.apognu.otter.utils.*
|
||||||
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.github.kittinunf.fuel.gson.gsonDeserializerOf
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -15,7 +12,7 @@ class RecentlyAddedRepository(override val context: Context?) : Repository<Track
|
||||||
override val cacheId = "home-recently-added"
|
override val cacheId = "home-recently-added"
|
||||||
|
|
||||||
override val upstream =
|
override val upstream =
|
||||||
HttpUpstream<Track, FunkwhaleResponse<Track>>(
|
HttpUpstream<Track, OtterResponse<Track>>(
|
||||||
HttpUpstream.Behavior.Single,
|
HttpUpstream.Behavior.Single,
|
||||||
"/api/v1/tracks/?playable=true&ordering=-creation_date",
|
"/api/v1/tracks/?playable=true&ordering=-creation_date",
|
||||||
object : TypeToken<TracksResponse>() {}.type,
|
object : TypeToken<TracksResponse>() {}.type,
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.github.apognu.otter.repositories.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.github.apognu.otter.repositories.HttpUpstream
|
import com.github.apognu.otter.repositories.HttpUpstream
|
||||||
import com.github.apognu.otter.repositories.Repository
|
import com.github.apognu.otter.repositories.Repository
|
||||||
import com.github.apognu.otter.utils.FunkwhaleResponse
|
import com.github.apognu.otter.utils.*
|
||||||
import com.github.apognu.otter.utils.PlaylistTrack
|
|
||||||
import com.github.apognu.otter.utils.PlaylistTracksCache
|
|
||||||
import com.github.apognu.otter.utils.PlaylistTracksResponse
|
|
||||||
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -15,7 +12,7 @@ class RecentlyListenedRepository(override val context: Context?) : Repository<Pl
|
||||||
override val cacheId = "home-recently-listened"
|
override val cacheId = "home-recently-listened"
|
||||||
|
|
||||||
override val upstream =
|
override val upstream =
|
||||||
HttpUpstream<PlaylistTrack, FunkwhaleResponse<PlaylistTrack>>(
|
HttpUpstream<PlaylistTrack, OtterResponse<PlaylistTrack>>(
|
||||||
HttpUpstream.Behavior.Single,
|
HttpUpstream.Behavior.Single,
|
||||||
"/api/v1/history/listenings/?playable=true",
|
"/api/v1/history/listenings/?playable=true",
|
||||||
object : TypeToken<PlaylistTracksResponse>() {}.type,
|
object : TypeToken<PlaylistTracksResponse>() {}.type,
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.github.apognu.otter.repositories.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.github.apognu.otter.repositories.HttpUpstream
|
import com.github.apognu.otter.repositories.HttpUpstream
|
||||||
import com.github.apognu.otter.repositories.Repository
|
import com.github.apognu.otter.repositories.Repository
|
||||||
import com.github.apognu.otter.utils.FunkwhaleResponse
|
import com.github.apognu.otter.utils.*
|
||||||
import com.github.apognu.otter.utils.Tag
|
|
||||||
import com.github.apognu.otter.utils.TagsCache
|
|
||||||
import com.github.apognu.otter.utils.TagsResponse
|
|
||||||
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
import com.github.kittinunf.fuel.gson.gsonDeserializerOf
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -15,7 +12,7 @@ class TagsRepository(override val context: Context?) : Repository<Tag, TagsCache
|
||||||
override val cacheId = "home-tags"
|
override val cacheId = "home-tags"
|
||||||
|
|
||||||
override val upstream =
|
override val upstream =
|
||||||
HttpUpstream<Tag, FunkwhaleResponse<Tag>>(
|
HttpUpstream<Tag, OtterResponse<Tag>>(
|
||||||
HttpUpstream.Behavior.Single,
|
HttpUpstream.Behavior.Single,
|
||||||
"/api/v1/tags/",
|
"/api/v1/tags/",
|
||||||
object : TypeToken<TagsResponse>() {}.type
|
object : TypeToken<TagsResponse>() {}.type
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<string name="login_error_hostname_https">Le nom d\'hôte Funkwhale devrait être sécurisé à travers HTTPS</string>
|
<string name="login_error_hostname_https">Le nom d\'hôte Funkwhale devrait être sécurisé à travers HTTPS</string>
|
||||||
<string name="login_error_userinfo">Nous n\'avons pas pu récupérer les informations à propos de votre utilisateur</string>
|
<string name="login_error_userinfo">Nous n\'avons pas pu récupérer les informations à propos de votre utilisateur</string>
|
||||||
<string name="toolbar_search">Rechercher</string>
|
<string name="toolbar_search">Rechercher</string>
|
||||||
|
<string name="title_discover">Découvrir</string>
|
||||||
<string name="title_downloads">Téléchargements</string>
|
<string name="title_downloads">Téléchargements</string>
|
||||||
<string name="title_settings">Paramètres</string>
|
<string name="title_settings">Paramètres</string>
|
||||||
<string name="title_oss_licences">Licences open source</string>
|
<string name="title_oss_licences">Licences open source</string>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<string name="login_error_hostname_https">The Funkwhale hostname should be secure through HTTPS</string>
|
<string name="login_error_hostname_https">The Funkwhale hostname should be secure through HTTPS</string>
|
||||||
<string name="login_error_userinfo">We could not retrieve information about your user</string>
|
<string name="login_error_userinfo">We could not retrieve information about your user</string>
|
||||||
<string name="toolbar_search">Search</string>
|
<string name="toolbar_search">Search</string>
|
||||||
|
<string name="title_discover">Discover</string>
|
||||||
<string name="title_downloads">Downloads</string>
|
<string name="title_downloads">Downloads</string>
|
||||||
<string name="title_settings">Settings</string>
|
<string name="title_settings">Settings</string>
|
||||||
<string name="title_oss_licences">Open source licences</string>
|
<string name="title_oss_licences">Open source licences</string>
|
||||||
|
|
Loading…
Reference in New Issue