diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/MainFragment.java b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/MainFragment.java index 91631658..9254a912 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/MainFragment.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/MainFragment.java @@ -117,24 +117,32 @@ public class MainFragment extends Fragment { final MergeAdapter adapter = new MergeAdapter(); adapter.addViews(Collections.singletonList(serverButton), true); + shouldUseId3 = Util.getShouldUseId3Tags(); + if (!ActiveServerProvider.Companion.isOffline()) { adapter.addView(musicTitle, false); adapter.addViews(asList(artistsButton, albumsButton, genresButton), true); + adapter.addView(songsTitle, false); adapter.addViews(asList(randomSongsButton, songsStarredButton), true); - adapter.addView(albumsTitle, false); - if (Util.getShouldUseId3Tags()) - { - shouldUseId3 = true; - adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton, albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true); - } - else - { - shouldUseId3 = false; - adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton, albumsHighestButton, albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true); - } + adapter.addView(albumsTitle, false); + adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton), true); + if (!shouldUseId3) + adapter.addView(albumsHighestButton, true); + adapter.addViews(asList(albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true); + + adapter.addView(videosTitle, false); + adapter.addViews(Collections.singletonList(videosButton), true); + } + else // Offline supported calls + { + adapter.addView(musicTitle, false); + adapter.addViews(asList(artistsButton, genresButton), true); + + adapter.addView(songsTitle, false); + adapter.addView(randomSongsButton, true); adapter.addView(videosTitle, false); adapter.addViews(Collections.singletonList(videosButton), true); @@ -261,5 +269,4 @@ public class MainFragment extends Fragment { { Navigation.findNavController(getView()).navigate(R.id.mainToServerSelector); } -} - +} diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/OfflineMusicService.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/OfflineMusicService.kt index 044fdc2d..af84bd78 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/OfflineMusicService.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/OfflineMusicService.kt @@ -18,7 +18,6 @@ import java.util.ArrayList import java.util.HashSet import java.util.LinkedList import java.util.Locale -import java.util.Random import java.util.concurrent.TimeUnit import java.util.regex.Pattern import org.koin.core.component.KoinComponent @@ -257,9 +256,9 @@ class OfflineMusicService : MusicService, KoinComponent { if (children.isEmpty()) { return result } - val random = Random() + children.shuffle() for (i in 0 until size) { - val file = children[random.nextInt(children.size)] + val file = children[i % children.size] result.addChild(createEntry(file, getName(file))) } return result